|
163 | 163 | }
|
164 | 164 | }
|
165 | 165 |
|
166 |
| - /** |
167 |
| - * @param myscriptTextWebElement |
168 |
| - */ |
169 |
| - function changeTextConfiguration(myscriptTextWebElement) { |
170 |
| - if (myscriptTextWebElement.myscriptcommonelement) { |
171 |
| - myscriptTextWebElement.myscriptcommonelement.configuration = buildTextConfiguration(myscriptTextWebElement); |
172 |
| - } |
173 |
| - } |
174 |
| - |
175 | 166 | function attachTextElementToDom(myscriptTextWebElement) {
|
176 | 167 | myscriptTextWebElement.myscriptcommonelement = textQsWrapper(myscriptTextWebElement).querySelector('myscript-common-element');
|
177 | 168 |
|
| 169 | + // Manage load events |
| 170 | + function loadListener(event) { |
| 171 | + LOG('text ' + event.type + ' event intercepted', event); |
| 172 | + myscriptTextWebElement.unloaded = false; |
| 173 | + myscriptTextWebElement.dispatchEvent(new CustomEvent(event.type.replace('myscript-common-element-', 'myscript-text-web-'), { detail: event.detail })); |
| 174 | + } |
| 175 | + |
178 | 176 | // Manage clear events
|
179 | 177 | function clearListener(event) {
|
180 | 178 | LOG('text ' + event.type + ' event intercepted', event);
|
|
198 | 196 | }
|
199 | 197 |
|
200 | 198 | myscriptTextWebElement.currentListeners = {};
|
| 199 | + ['myscript-common-element-load'].forEach(function (type) { |
| 200 | + myscriptTextWebElement.currentListeners[type] = loadListener; |
| 201 | + }); |
201 | 202 | ['myscript-common-element-result'].forEach(function (type) {
|
202 | 203 | myscriptTextWebElement.currentListeners[type] = resultListener;
|
203 | 204 | });
|
|
211 | 212 | Object.keys(myscriptTextWebElement.currentListeners).forEach(function (type) {
|
212 | 213 | myscriptTextWebElement.myscriptcommonelement.addEventListener(type, myscriptTextWebElement.currentListeners[type])
|
213 | 214 | });
|
214 |
| - myscriptTextWebElement.configuration = buildTextConfiguration(myscriptTextWebElement); |
215 |
| - myscriptTextWebElement.unloaded = false; |
216 | 215 | LOG('text-web attached');
|
217 | 216 | }
|
218 | 217 |
|
|
221 | 220 | Object.keys(myscriptTextWebElement.currentListeners).forEach(function (type) {
|
222 | 221 | myscriptTextWebElement.myscriptcommonelement.removeEventListener(type, myscriptTextWebElement.currentListeners[type])
|
223 | 222 | });
|
224 |
| - myscriptTextWebElement.unloaded = true; |
225 | 223 | LOG('text-web detached');
|
226 | 224 | }
|
227 | 225 |
|
|
343 | 341 | */
|
344 | 342 | unloaded: {
|
345 | 343 | type: Boolean,
|
346 |
| - value: false, |
| 344 | + value: true, |
347 | 345 | notify: true,
|
348 | 346 | reflectToAttribute: true,
|
349 | 347 | observer: 'unloadedChanged'
|
|
694 | 692 | //-----------------------------------------------------------------------
|
695 | 693 | unloadedChanged: function (unloaded) {
|
696 | 694 | LOG('text unloaded changed', unloaded);
|
697 |
| - if (this.myscriptcommonelement && !this.initializing && unloaded !== true) { |
698 |
| - this.result = {}; |
699 |
| - this.candidates = []; |
700 |
| - this.resultlabel = undefined; |
701 |
| - this.myscriptcommonelement.unloaded = true; |
702 |
| - changeTextConfiguration(this); |
703 |
| - this.myscriptcommonelement.unloaded = false; |
| 695 | + this.result = {}; |
| 696 | + this.candidates = []; |
| 697 | + this.resultlabel = undefined; |
| 698 | + buildTextConfiguration(this); |
| 699 | + if (unloaded === true) { |
| 700 | + if (this.myscriptcommonelement && !this.initializing) { |
| 701 | + this.myscriptcommonelement.unloaded = true; |
| 702 | + } |
704 | 703 | }
|
705 | 704 | },
|
706 | 705 | // Will be renamed connected with pure custom element support
|
707 | 706 | attached: function () {
|
708 | 707 | this.initializing = true;
|
709 | 708 | LOG('text-web attached callback');
|
710 | 709 | attachTextElementToDom(this);
|
711 |
| - // FIXME: Ugly hack to apply configuration |
712 |
| - this.myscriptcommonelement.unloaded = true; |
713 |
| - this.myscriptcommonelement.unloaded = false; |
714 | 710 | this.initializing = false;
|
715 | 711 | },
|
716 | 712 | detached: function () {
|
|
0 commit comments