native-document 1.0.81 → 1.0.83
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/native-document.components.min.js +9 -131
- package/dist/native-document.dev.js +116 -103
- package/dist/native-document.dev.js.map +1 -1
- package/dist/native-document.devtools.min.js +1 -1
- package/dist/native-document.min.js +1 -1
- package/package.json +1 -1
- package/src/core/data/ObservableArray.js +3 -1
- package/src/core/data/ObservableItem.js +15 -6
- package/src/core/data/observable-helpers/computed.js +3 -2
- package/src/core/elements/anchor.js +3 -1
- package/src/core/elements/control/for-each-array.js +1 -1
- package/src/core/utils/plugins-manager.js +66 -62
- package/src/core/utils/validator.js +2 -2
- package/src/core/wrappers/ElementCreator.js +9 -16
- package/src/core/wrappers/HtmlElementWrapper.js +3 -8
- package/src/core/wrappers/NDElement.js +6 -3
- package/src/core/wrappers/prototypes/nd-element-extensions.js +3 -1
|
@@ -362,80 +362,6 @@ var NativeComponents = (function (exports) {
|
|
|
362
362
|
return this.observable.cleanup();
|
|
363
363
|
};
|
|
364
364
|
|
|
365
|
-
const PluginsManager = (function() {
|
|
366
|
-
|
|
367
|
-
const $plugins = new Map();
|
|
368
|
-
const $pluginByEvents = new Map();
|
|
369
|
-
|
|
370
|
-
return {
|
|
371
|
-
list() {
|
|
372
|
-
return $pluginByEvents;
|
|
373
|
-
},
|
|
374
|
-
add(plugin, name){
|
|
375
|
-
if (!plugin || typeof plugin !== 'object') {
|
|
376
|
-
throw new Error(`Plugin ${name} must be an object`);
|
|
377
|
-
}
|
|
378
|
-
name = name || plugin.name;
|
|
379
|
-
if (!name || typeof name !== 'string') {
|
|
380
|
-
throw new Error(`Please, provide a valid plugin name`);
|
|
381
|
-
}
|
|
382
|
-
if($plugins.has(name)) {
|
|
383
|
-
return;
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
plugin.$name = name;
|
|
387
|
-
$plugins.set(name ,plugin);
|
|
388
|
-
if(typeof plugin?.init === 'function') {
|
|
389
|
-
plugin.init();
|
|
390
|
-
}
|
|
391
|
-
for(const methodName in plugin) {
|
|
392
|
-
if(/^on[A-Z]/.test(methodName)) {
|
|
393
|
-
const eventName = methodName.replace(/^on/, '');
|
|
394
|
-
if(!$pluginByEvents.has(eventName)) {
|
|
395
|
-
$pluginByEvents.set(eventName, new Set());
|
|
396
|
-
}
|
|
397
|
-
$pluginByEvents.get(eventName).add(plugin);
|
|
398
|
-
}
|
|
399
|
-
}
|
|
400
|
-
},
|
|
401
|
-
remove(pluginName){
|
|
402
|
-
if(!$plugins.has(pluginName)) {
|
|
403
|
-
return;
|
|
404
|
-
}
|
|
405
|
-
const plugin = $plugins.get(pluginName);
|
|
406
|
-
if(typeof plugin.cleanup === 'function') {
|
|
407
|
-
plugin.cleanup();
|
|
408
|
-
}
|
|
409
|
-
for(const [name, sets] of $pluginByEvents.entries() ) {
|
|
410
|
-
if(sets.has(plugin)) {
|
|
411
|
-
sets.delete(plugin);
|
|
412
|
-
}
|
|
413
|
-
if(sets.size === 0) {
|
|
414
|
-
$pluginByEvents.delete(name);
|
|
415
|
-
}
|
|
416
|
-
}
|
|
417
|
-
$plugins.delete(pluginName);
|
|
418
|
-
},
|
|
419
|
-
emit(eventName, ...data) {
|
|
420
|
-
if(!$pluginByEvents.has(eventName)) {
|
|
421
|
-
return;
|
|
422
|
-
}
|
|
423
|
-
const plugins = $pluginByEvents.get(eventName);
|
|
424
|
-
|
|
425
|
-
for(const plugin of plugins) {
|
|
426
|
-
const callback = plugin['on'+eventName];
|
|
427
|
-
if(typeof callback === 'function') {
|
|
428
|
-
try{
|
|
429
|
-
callback.call(plugin, ...data);
|
|
430
|
-
} catch (error) {
|
|
431
|
-
DebugManager.error('Plugin Manager', `Error in plugin ${plugin.$name} for event ${eventName}`, error);
|
|
432
|
-
}
|
|
433
|
-
}
|
|
434
|
-
}
|
|
435
|
-
}
|
|
436
|
-
};
|
|
437
|
-
}());
|
|
438
|
-
|
|
439
365
|
const ObservableWhen = function(observer, value) {
|
|
440
366
|
this.$target = value;
|
|
441
367
|
this.$observer = observer;
|
|
@@ -560,8 +486,6 @@ var NativeComponents = (function (exports) {
|
|
|
560
486
|
this.$initialValue = Validator.isObject(value) ? deepClone(value) : value;
|
|
561
487
|
}
|
|
562
488
|
}
|
|
563
|
-
|
|
564
|
-
PluginsManager.emit('CreateObservable', this);
|
|
565
489
|
}
|
|
566
490
|
|
|
567
491
|
Object.defineProperty(ObservableItem.prototype, '$value', {
|
|
@@ -686,10 +610,8 @@ var NativeComponents = (function (exports) {
|
|
|
686
610
|
}
|
|
687
611
|
this.$previousValue = this.$currentValue;
|
|
688
612
|
this.$currentValue = newValue;
|
|
689
|
-
PluginsManager.emit('ObservableBeforeChange', this);
|
|
690
613
|
this.trigger();
|
|
691
614
|
this.$previousValue = null;
|
|
692
|
-
PluginsManager.emit('ObservableAfterChange', this);
|
|
693
615
|
};
|
|
694
616
|
|
|
695
617
|
ObservableItem.prototype.val = function() {
|
|
@@ -749,11 +671,9 @@ var NativeComponents = (function (exports) {
|
|
|
749
671
|
|
|
750
672
|
this.$listeners.push(callback);
|
|
751
673
|
this.assocTrigger();
|
|
752
|
-
PluginsManager.emit('ObservableSubscribe', this, target);
|
|
753
674
|
return () => {
|
|
754
675
|
this.unsubscribe(callback);
|
|
755
676
|
this.assocTrigger();
|
|
756
|
-
PluginsManager.emit('ObservableUnsubscribe', this);
|
|
757
677
|
};
|
|
758
678
|
};
|
|
759
679
|
|
|
@@ -973,7 +893,6 @@ var NativeComponents = (function (exports) {
|
|
|
973
893
|
function NDElement(element) {
|
|
974
894
|
this.$element = element;
|
|
975
895
|
this.$observer = null;
|
|
976
|
-
PluginsManager.emit('NDElementCreated', element, this);
|
|
977
896
|
}
|
|
978
897
|
|
|
979
898
|
NDElement.prototype.__$isNDElement = true;
|
|
@@ -1132,17 +1051,9 @@ var NativeComponents = (function (exports) {
|
|
|
1132
1051
|
NDElement.prototype[name] = method;
|
|
1133
1052
|
}
|
|
1134
1053
|
|
|
1135
|
-
PluginsManager.emit('NDElementExtended', methods);
|
|
1136
|
-
|
|
1137
1054
|
return NDElement;
|
|
1138
1055
|
};
|
|
1139
1056
|
|
|
1140
|
-
function TemplateBinding(hydrate) {
|
|
1141
|
-
this.$hydrate = hydrate;
|
|
1142
|
-
}
|
|
1143
|
-
|
|
1144
|
-
TemplateBinding.prototype.__$isTemplateBinding = true;
|
|
1145
|
-
|
|
1146
1057
|
const COMMON_NODE_TYPES = {
|
|
1147
1058
|
ELEMENT: 1,
|
|
1148
1059
|
TEXT: 3,
|
|
@@ -1152,10 +1063,10 @@ var NativeComponents = (function (exports) {
|
|
|
1152
1063
|
|
|
1153
1064
|
const Validator = {
|
|
1154
1065
|
isObservable(value) {
|
|
1155
|
-
return value?.__$isObservable
|
|
1066
|
+
return value?.__$isObservable;
|
|
1156
1067
|
},
|
|
1157
1068
|
isTemplateBinding(value) {
|
|
1158
|
-
return value?.__$isTemplateBinding
|
|
1069
|
+
return value?.__$isTemplateBinding;
|
|
1159
1070
|
},
|
|
1160
1071
|
isObservableWhenResult(value) {
|
|
1161
1072
|
return value && (value.__$isObservableWhen || (typeof value === 'object' && '$target' in value && '$observer' in value));
|
|
@@ -1411,6 +1322,7 @@ var NativeComponents = (function (exports) {
|
|
|
1411
1322
|
|
|
1412
1323
|
return anchorFragment;
|
|
1413
1324
|
}
|
|
1325
|
+
DocumentFragment.prototype.setAttribute = () => {};
|
|
1414
1326
|
|
|
1415
1327
|
const BOOLEAN_ATTRIBUTES = new Set([
|
|
1416
1328
|
'checked',
|
|
@@ -1524,10 +1436,6 @@ var NativeComponents = (function (exports) {
|
|
|
1524
1436
|
this.subscribe(toggleElementClass.bind(null, element, className));
|
|
1525
1437
|
};
|
|
1526
1438
|
|
|
1527
|
-
TemplateBinding.prototype.bindNdClass = function(element, className) {
|
|
1528
|
-
this.$hydrate(element, className);
|
|
1529
|
-
};
|
|
1530
|
-
|
|
1531
1439
|
function toggleElementClass(element, className, shouldAdd) {
|
|
1532
1440
|
element.classes.toggle(className, shouldAdd);
|
|
1533
1441
|
}
|
|
@@ -1726,14 +1634,9 @@ var NativeComponents = (function (exports) {
|
|
|
1726
1634
|
|
|
1727
1635
|
Function.prototype.toNdElement = function () {
|
|
1728
1636
|
const child = this;
|
|
1729
|
-
PluginsManager.emit('BeforeProcessComponent', child);
|
|
1730
1637
|
return ElementCreator.getChild(child());
|
|
1731
1638
|
};
|
|
1732
1639
|
|
|
1733
|
-
TemplateBinding.prototype.toNdElement = function () {
|
|
1734
|
-
return ElementCreator.createHydratableNode(null, this);
|
|
1735
|
-
};
|
|
1736
|
-
|
|
1737
1640
|
String.prototype.handleNdAttribute = function(element, attributeName) {
|
|
1738
1641
|
element.setAttribute(attributeName, this);
|
|
1739
1642
|
};
|
|
@@ -1747,10 +1650,6 @@ var NativeComponents = (function (exports) {
|
|
|
1747
1650
|
bindAttributeWithObservable(element, attributeName, this);
|
|
1748
1651
|
};
|
|
1749
1652
|
|
|
1750
|
-
TemplateBinding.prototype.handleNdAttribute = function(element, attributeName) {
|
|
1751
|
-
this.$hydrate(element, attributeName);
|
|
1752
|
-
};
|
|
1753
|
-
|
|
1754
1653
|
const $nodeCache = new Map();
|
|
1755
1654
|
let $textNodeCache = null;
|
|
1756
1655
|
|
|
@@ -1805,8 +1704,9 @@ var NativeComponents = (function (exports) {
|
|
|
1805
1704
|
*/
|
|
1806
1705
|
createElement(name) {
|
|
1807
1706
|
if(name) {
|
|
1808
|
-
|
|
1809
|
-
|
|
1707
|
+
const cacheNode = $nodeCache.get(name);
|
|
1708
|
+
if(cacheNode) {
|
|
1709
|
+
return cacheNode.cloneNode();
|
|
1810
1710
|
}
|
|
1811
1711
|
const node = document.createElement(name);
|
|
1812
1712
|
$nodeCache.set(name, node);
|
|
@@ -1821,12 +1721,10 @@ var NativeComponents = (function (exports) {
|
|
|
1821
1721
|
*/
|
|
1822
1722
|
processChildren(children, parent) {
|
|
1823
1723
|
if(children === null) return;
|
|
1824
|
-
PluginsManager.emit('BeforeProcessChildren', parent);
|
|
1825
1724
|
let child = this.getChild(children);
|
|
1826
1725
|
if(child) {
|
|
1827
1726
|
parent.appendChild(child);
|
|
1828
1727
|
}
|
|
1829
|
-
PluginsManager.emit('AfterProcessChildren', parent);
|
|
1830
1728
|
},
|
|
1831
1729
|
getChild(child) {
|
|
1832
1730
|
if(child == null) {
|
|
@@ -1849,21 +1747,9 @@ var NativeComponents = (function (exports) {
|
|
|
1849
1747
|
* @param {Object} attributes
|
|
1850
1748
|
*/
|
|
1851
1749
|
processAttributes(element, attributes) {
|
|
1852
|
-
if(Validator.isFragment(element)) return;
|
|
1853
1750
|
if (attributes) {
|
|
1854
1751
|
AttributesWrapper(element, attributes);
|
|
1855
1752
|
}
|
|
1856
|
-
},
|
|
1857
|
-
/**
|
|
1858
|
-
*
|
|
1859
|
-
* @param {HTMLElement} element
|
|
1860
|
-
* @param {Object} attributes
|
|
1861
|
-
* @param {?Function} customWrapper
|
|
1862
|
-
* @returns {HTMLElement|DocumentFragment}
|
|
1863
|
-
*/
|
|
1864
|
-
setup(element, attributes, customWrapper) {
|
|
1865
|
-
PluginsManager.emit('Setup', element, attributes, customWrapper);
|
|
1866
|
-
return element;
|
|
1867
1753
|
}
|
|
1868
1754
|
};
|
|
1869
1755
|
|
|
@@ -2160,14 +2046,9 @@ var NativeComponents = (function (exports) {
|
|
|
2160
2046
|
let element = ElementCreator.createElement($tagName);
|
|
2161
2047
|
let finalElement = (customWrapper && typeof customWrapper === 'function') ? customWrapper(element) : element;
|
|
2162
2048
|
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
if(children) {
|
|
2167
|
-
ElementCreator.processChildren(children, finalElement);
|
|
2168
|
-
}
|
|
2169
|
-
|
|
2170
|
-
return ElementCreator.setup(finalElement, attributes, customWrapper);
|
|
2049
|
+
ElementCreator.processAttributes(finalElement, attributes);
|
|
2050
|
+
ElementCreator.processChildren(children, finalElement);
|
|
2051
|
+
return finalElement;
|
|
2171
2052
|
}
|
|
2172
2053
|
|
|
2173
2054
|
/**
|
|
@@ -2292,7 +2173,6 @@ var NativeComponents = (function (exports) {
|
|
|
2292
2173
|
}
|
|
2293
2174
|
|
|
2294
2175
|
ObservableItem.call(this, target, configs);
|
|
2295
|
-
PluginsManager.emit('CreateObservableArray', this);
|
|
2296
2176
|
};
|
|
2297
2177
|
|
|
2298
2178
|
ObservableArray.prototype = Object.create(ObservableItem.prototype);
|
|
@@ -2692,8 +2572,6 @@ var NativeComponents = (function (exports) {
|
|
|
2692
2572
|
const observable = new ObservableItem(initialValue);
|
|
2693
2573
|
const updatedValue = nextTick(() => observable.set(callback()));
|
|
2694
2574
|
|
|
2695
|
-
PluginsManager.emit('CreateObservableComputed', observable, dependencies);
|
|
2696
|
-
|
|
2697
2575
|
if(Validator.isFunction(dependencies)) {
|
|
2698
2576
|
if(!Validator.isObservable(dependencies.$observer)) {
|
|
2699
2577
|
throw new NativeDocumentError('Observable.computed : dependencies must be valid batch function');
|
|
@@ -141,79 +141,85 @@ var NativeDocument = (function (exports) {
|
|
|
141
141
|
return this.observable.cleanup();
|
|
142
142
|
};
|
|
143
143
|
|
|
144
|
-
|
|
144
|
+
let PluginsManager$1 = null;
|
|
145
145
|
|
|
146
|
-
|
|
147
|
-
|
|
146
|
+
{
|
|
147
|
+
PluginsManager$1 = (function() {
|
|
148
148
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
return $pluginByEvents;
|
|
152
|
-
},
|
|
153
|
-
add(plugin, name){
|
|
154
|
-
if (!plugin || typeof plugin !== 'object') {
|
|
155
|
-
throw new Error(`Plugin ${name} must be an object`);
|
|
156
|
-
}
|
|
157
|
-
name = name || plugin.name;
|
|
158
|
-
if (!name || typeof name !== 'string') {
|
|
159
|
-
throw new Error(`Please, provide a valid plugin name`);
|
|
160
|
-
}
|
|
161
|
-
if($plugins.has(name)) {
|
|
162
|
-
return;
|
|
163
|
-
}
|
|
149
|
+
const $plugins = new Map();
|
|
150
|
+
const $pluginByEvents = new Map();
|
|
164
151
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
152
|
+
return {
|
|
153
|
+
list() {
|
|
154
|
+
return $pluginByEvents;
|
|
155
|
+
},
|
|
156
|
+
add(plugin, name){
|
|
157
|
+
if (!plugin || typeof plugin !== 'object') {
|
|
158
|
+
throw new Error(`Plugin ${name} must be an object`);
|
|
159
|
+
}
|
|
160
|
+
name = name || plugin.name;
|
|
161
|
+
if (!name || typeof name !== 'string') {
|
|
162
|
+
throw new Error(`Please, provide a valid plugin name`);
|
|
163
|
+
}
|
|
164
|
+
if($plugins.has(name)) {
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
plugin.$name = name;
|
|
169
|
+
$plugins.set(name ,plugin);
|
|
170
|
+
if(typeof plugin?.init === 'function') {
|
|
171
|
+
plugin.init();
|
|
172
|
+
}
|
|
173
|
+
for(const methodName in plugin) {
|
|
174
|
+
if(/^on[A-Z]/.test(methodName)) {
|
|
175
|
+
const eventName = methodName.replace(/^on/, '');
|
|
176
|
+
if(!$pluginByEvents.has(eventName)) {
|
|
177
|
+
$pluginByEvents.set(eventName, new Set());
|
|
178
|
+
}
|
|
179
|
+
$pluginByEvents.get(eventName).add(plugin);
|
|
175
180
|
}
|
|
176
|
-
$pluginByEvents.get(eventName).add(plugin);
|
|
177
181
|
}
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
return;
|
|
183
|
-
}
|
|
184
|
-
const plugin = $plugins.get(pluginName);
|
|
185
|
-
if(typeof plugin.cleanup === 'function') {
|
|
186
|
-
plugin.cleanup();
|
|
187
|
-
}
|
|
188
|
-
for(const [name, sets] of $pluginByEvents.entries() ) {
|
|
189
|
-
if(sets.has(plugin)) {
|
|
190
|
-
sets.delete(plugin);
|
|
182
|
+
},
|
|
183
|
+
remove(pluginName){
|
|
184
|
+
if(!$plugins.has(pluginName)) {
|
|
185
|
+
return;
|
|
191
186
|
}
|
|
192
|
-
|
|
193
|
-
|
|
187
|
+
const plugin = $plugins.get(pluginName);
|
|
188
|
+
if(typeof plugin.cleanup === 'function') {
|
|
189
|
+
plugin.cleanup();
|
|
194
190
|
}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
if(
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
191
|
+
for(const [name, sets] of $pluginByEvents.entries() ) {
|
|
192
|
+
if(sets.has(plugin)) {
|
|
193
|
+
sets.delete(plugin);
|
|
194
|
+
}
|
|
195
|
+
if(sets.size === 0) {
|
|
196
|
+
$pluginByEvents.delete(name);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
$plugins.delete(pluginName);
|
|
200
|
+
},
|
|
201
|
+
emit(eventName, ...data) {
|
|
202
|
+
if(!$pluginByEvents.has(eventName)) {
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
const plugins = $pluginByEvents.get(eventName);
|
|
206
|
+
|
|
207
|
+
for(const plugin of plugins) {
|
|
208
|
+
const callback = plugin['on'+eventName];
|
|
209
|
+
if(typeof callback === 'function') {
|
|
210
|
+
try{
|
|
211
|
+
callback.call(plugin, ...data);
|
|
212
|
+
} catch (error) {
|
|
213
|
+
DebugManager$1.error('Plugin Manager', `Error in plugin ${plugin.$name} for event ${eventName}`, error);
|
|
214
|
+
}
|
|
211
215
|
}
|
|
212
216
|
}
|
|
213
217
|
}
|
|
214
|
-
}
|
|
215
|
-
};
|
|
216
|
-
}
|
|
218
|
+
};
|
|
219
|
+
}());
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
var PluginsManager = PluginsManager$1;
|
|
217
223
|
|
|
218
224
|
const ObservableWhen = function(observer, value) {
|
|
219
225
|
this.$target = value;
|
|
@@ -334,8 +340,9 @@ var NativeDocument = (function (exports) {
|
|
|
334
340
|
this.$initialValue = Validator.isObject(value) ? deepClone(value) : value;
|
|
335
341
|
}
|
|
336
342
|
}
|
|
337
|
-
|
|
338
|
-
|
|
343
|
+
{
|
|
344
|
+
PluginsManager.emit('CreateObservable', this);
|
|
345
|
+
}
|
|
339
346
|
}
|
|
340
347
|
|
|
341
348
|
Object.defineProperty(ObservableItem.prototype, '$value', {
|
|
@@ -460,10 +467,14 @@ var NativeDocument = (function (exports) {
|
|
|
460
467
|
}
|
|
461
468
|
this.$previousValue = this.$currentValue;
|
|
462
469
|
this.$currentValue = newValue;
|
|
463
|
-
|
|
470
|
+
{
|
|
471
|
+
PluginsManager.emit('ObservableBeforeChange', this);
|
|
472
|
+
}
|
|
464
473
|
this.trigger();
|
|
465
474
|
this.$previousValue = null;
|
|
466
|
-
|
|
475
|
+
{
|
|
476
|
+
PluginsManager.emit('ObservableAfterChange', this);
|
|
477
|
+
}
|
|
467
478
|
};
|
|
468
479
|
|
|
469
480
|
ObservableItem.prototype.val = function() {
|
|
@@ -523,11 +534,15 @@ var NativeDocument = (function (exports) {
|
|
|
523
534
|
|
|
524
535
|
this.$listeners.push(callback);
|
|
525
536
|
this.assocTrigger();
|
|
526
|
-
|
|
537
|
+
{
|
|
538
|
+
PluginsManager.emit('ObservableSubscribe', this, target);
|
|
539
|
+
}
|
|
527
540
|
return () => {
|
|
528
541
|
this.unsubscribe(callback);
|
|
529
542
|
this.assocTrigger();
|
|
530
|
-
|
|
543
|
+
{
|
|
544
|
+
PluginsManager.emit('ObservableUnsubscribe', this);
|
|
545
|
+
}
|
|
531
546
|
};
|
|
532
547
|
};
|
|
533
548
|
|
|
@@ -747,7 +762,9 @@ var NativeDocument = (function (exports) {
|
|
|
747
762
|
function NDElement(element) {
|
|
748
763
|
this.$element = element;
|
|
749
764
|
this.$observer = null;
|
|
750
|
-
|
|
765
|
+
{
|
|
766
|
+
PluginsManager.emit('NDElementCreated', element, this);
|
|
767
|
+
}
|
|
751
768
|
}
|
|
752
769
|
|
|
753
770
|
NDElement.prototype.__$isNDElement = true;
|
|
@@ -916,8 +933,9 @@ var NativeDocument = (function (exports) {
|
|
|
916
933
|
|
|
917
934
|
NDElement.prototype[name] = method;
|
|
918
935
|
}
|
|
919
|
-
|
|
920
|
-
|
|
936
|
+
{
|
|
937
|
+
PluginsManager.emit('NDElementExtended', methods);
|
|
938
|
+
}
|
|
921
939
|
|
|
922
940
|
return NDElement;
|
|
923
941
|
};
|
|
@@ -937,10 +955,10 @@ var NativeDocument = (function (exports) {
|
|
|
937
955
|
|
|
938
956
|
const Validator = {
|
|
939
957
|
isObservable(value) {
|
|
940
|
-
return value?.__$isObservable
|
|
958
|
+
return value?.__$isObservable;
|
|
941
959
|
},
|
|
942
960
|
isTemplateBinding(value) {
|
|
943
|
-
return value?.__$isTemplateBinding
|
|
961
|
+
return value?.__$isTemplateBinding;
|
|
944
962
|
},
|
|
945
963
|
isObservableWhenResult(value) {
|
|
946
964
|
return value && (value.__$isObservableWhen || (typeof value === 'object' && '$target' in value && '$observer' in value));
|
|
@@ -1227,6 +1245,8 @@ var NativeDocument = (function (exports) {
|
|
|
1227
1245
|
return anchor;
|
|
1228
1246
|
}
|
|
1229
1247
|
|
|
1248
|
+
DocumentFragment.prototype.setAttribute = () => {};
|
|
1249
|
+
|
|
1230
1250
|
const BOOLEAN_ATTRIBUTES = new Set([
|
|
1231
1251
|
'checked',
|
|
1232
1252
|
'selected',
|
|
@@ -1544,7 +1564,9 @@ var NativeDocument = (function (exports) {
|
|
|
1544
1564
|
|
|
1545
1565
|
Function.prototype.toNdElement = function () {
|
|
1546
1566
|
const child = this;
|
|
1547
|
-
|
|
1567
|
+
{
|
|
1568
|
+
PluginsManager.emit('BeforeProcessComponent', child);
|
|
1569
|
+
}
|
|
1548
1570
|
return ElementCreator.getChild(child());
|
|
1549
1571
|
};
|
|
1550
1572
|
|
|
@@ -1623,8 +1645,9 @@ var NativeDocument = (function (exports) {
|
|
|
1623
1645
|
*/
|
|
1624
1646
|
createElement(name) {
|
|
1625
1647
|
if(name) {
|
|
1626
|
-
|
|
1627
|
-
|
|
1648
|
+
const cacheNode = $nodeCache.get(name);
|
|
1649
|
+
if(cacheNode) {
|
|
1650
|
+
return cacheNode.cloneNode();
|
|
1628
1651
|
}
|
|
1629
1652
|
const node = document.createElement(name);
|
|
1630
1653
|
$nodeCache.set(name, node);
|
|
@@ -1639,12 +1662,16 @@ var NativeDocument = (function (exports) {
|
|
|
1639
1662
|
*/
|
|
1640
1663
|
processChildren(children, parent) {
|
|
1641
1664
|
if(children === null) return;
|
|
1642
|
-
|
|
1665
|
+
{
|
|
1666
|
+
PluginsManager.emit('BeforeProcessChildren', parent);
|
|
1667
|
+
}
|
|
1643
1668
|
let child = this.getChild(children);
|
|
1644
1669
|
if(child) {
|
|
1645
1670
|
parent.appendChild(child);
|
|
1646
1671
|
}
|
|
1647
|
-
|
|
1672
|
+
{
|
|
1673
|
+
PluginsManager.emit('AfterProcessChildren', parent);
|
|
1674
|
+
}
|
|
1648
1675
|
},
|
|
1649
1676
|
getChild(child) {
|
|
1650
1677
|
if(child == null) {
|
|
@@ -1667,21 +1694,9 @@ var NativeDocument = (function (exports) {
|
|
|
1667
1694
|
* @param {Object} attributes
|
|
1668
1695
|
*/
|
|
1669
1696
|
processAttributes(element, attributes) {
|
|
1670
|
-
if(Validator.isFragment(element)) return;
|
|
1671
1697
|
if (attributes) {
|
|
1672
1698
|
AttributesWrapper(element, attributes);
|
|
1673
1699
|
}
|
|
1674
|
-
},
|
|
1675
|
-
/**
|
|
1676
|
-
*
|
|
1677
|
-
* @param {HTMLElement} element
|
|
1678
|
-
* @param {Object} attributes
|
|
1679
|
-
* @param {?Function} customWrapper
|
|
1680
|
-
* @returns {HTMLElement|DocumentFragment}
|
|
1681
|
-
*/
|
|
1682
|
-
setup(element, attributes, customWrapper) {
|
|
1683
|
-
PluginsManager.emit('Setup', element, attributes, customWrapper);
|
|
1684
|
-
return element;
|
|
1685
1700
|
}
|
|
1686
1701
|
};
|
|
1687
1702
|
|
|
@@ -2099,14 +2114,9 @@ var NativeDocument = (function (exports) {
|
|
|
2099
2114
|
let element = ElementCreator.createElement($tagName);
|
|
2100
2115
|
let finalElement = (customWrapper && typeof customWrapper === 'function') ? customWrapper(element) : element;
|
|
2101
2116
|
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
if(children) {
|
|
2106
|
-
ElementCreator.processChildren(children, finalElement);
|
|
2107
|
-
}
|
|
2108
|
-
|
|
2109
|
-
return ElementCreator.setup(finalElement, attributes, customWrapper);
|
|
2117
|
+
ElementCreator.processAttributes(finalElement, attributes);
|
|
2118
|
+
ElementCreator.processChildren(children, finalElement);
|
|
2119
|
+
return finalElement;
|
|
2110
2120
|
}
|
|
2111
2121
|
|
|
2112
2122
|
/**
|
|
@@ -2897,7 +2907,9 @@ var NativeDocument = (function (exports) {
|
|
|
2897
2907
|
}
|
|
2898
2908
|
|
|
2899
2909
|
ObservableItem.call(this, target, configs);
|
|
2900
|
-
|
|
2910
|
+
{
|
|
2911
|
+
PluginsManager.emit('CreateObservableArray', this);
|
|
2912
|
+
}
|
|
2901
2913
|
};
|
|
2902
2914
|
|
|
2903
2915
|
ObservableArray.prototype = Object.create(ObservableItem.prototype);
|
|
@@ -3296,8 +3308,9 @@ var NativeDocument = (function (exports) {
|
|
|
3296
3308
|
const initialValue = callback();
|
|
3297
3309
|
const observable = new ObservableItem(initialValue);
|
|
3298
3310
|
const updatedValue = nextTick(() => observable.set(callback()));
|
|
3299
|
-
|
|
3300
|
-
|
|
3311
|
+
{
|
|
3312
|
+
PluginsManager.emit('CreateObservableComputed', observable, dependencies);
|
|
3313
|
+
}
|
|
3301
3314
|
|
|
3302
3315
|
if(Validator.isFunction(dependencies)) {
|
|
3303
3316
|
if(!Validator.isObservable(dependencies.$observer)) {
|
|
@@ -3618,7 +3631,7 @@ var NativeDocument = (function (exports) {
|
|
|
3618
3631
|
if(child) {
|
|
3619
3632
|
cache.set(item, {
|
|
3620
3633
|
child,
|
|
3621
|
-
indexObserver
|
|
3634
|
+
indexObserver
|
|
3622
3635
|
});
|
|
3623
3636
|
return child;
|
|
3624
3637
|
}
|