native-document 1.0.89 → 1.0.90
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 +43 -63
- package/dist/native-document.dev.js +79 -101
- 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/ObservableChecker.js +4 -4
- package/src/core/data/ObservableItem.js +23 -33
- package/src/core/data/ObservableWhen.js +2 -2
- package/src/core/wrappers/AttributesWrapper.js +18 -28
- package/src/core/wrappers/prototypes/bind-class-extensions.js +3 -7
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
var NativeDocument = (function (exports) {
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
let DebugManager
|
|
4
|
+
let DebugManager = {};
|
|
5
5
|
|
|
6
6
|
{
|
|
7
|
-
DebugManager
|
|
7
|
+
DebugManager = {
|
|
8
8
|
enabled: false,
|
|
9
9
|
|
|
10
10
|
enable() {
|
|
@@ -35,7 +35,7 @@ var NativeDocument = (function (exports) {
|
|
|
35
35
|
};
|
|
36
36
|
|
|
37
37
|
}
|
|
38
|
-
var DebugManager = DebugManager
|
|
38
|
+
var DebugManager$1 = DebugManager;
|
|
39
39
|
|
|
40
40
|
const MemoryManager = (function() {
|
|
41
41
|
|
|
@@ -84,7 +84,7 @@ var NativeDocument = (function (exports) {
|
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
86
|
if (cleanedCount > 0) {
|
|
87
|
-
DebugManager.log('Memory Auto Clean', `🧹 Cleaned ${cleanedCount} orphaned observables`);
|
|
87
|
+
DebugManager$1.log('Memory Auto Clean', `🧹 Cleaned ${cleanedCount} orphaned observables`);
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
};
|
|
@@ -113,10 +113,10 @@ var NativeDocument = (function (exports) {
|
|
|
113
113
|
|
|
114
114
|
ObservableChecker.prototype.__$isObservableChecker = true;
|
|
115
115
|
|
|
116
|
-
ObservableChecker.prototype.subscribe = function(callback
|
|
117
|
-
const unSubscribe = this.observable.subscribe((value
|
|
118
|
-
callback && callback(this.checker(value)
|
|
119
|
-
}
|
|
116
|
+
ObservableChecker.prototype.subscribe = function(callback) {
|
|
117
|
+
const unSubscribe = this.observable.subscribe((value) => {
|
|
118
|
+
callback && callback(this.checker(value));
|
|
119
|
+
});
|
|
120
120
|
this.unSubscriptions.push(unSubscribe);
|
|
121
121
|
return unSubscribe;
|
|
122
122
|
};
|
|
@@ -141,10 +141,10 @@ var NativeDocument = (function (exports) {
|
|
|
141
141
|
return this.observable.cleanup();
|
|
142
142
|
};
|
|
143
143
|
|
|
144
|
-
let PluginsManager
|
|
144
|
+
let PluginsManager = null;
|
|
145
145
|
|
|
146
146
|
{
|
|
147
|
-
PluginsManager
|
|
147
|
+
PluginsManager = (function() {
|
|
148
148
|
|
|
149
149
|
const $plugins = new Map();
|
|
150
150
|
const $pluginByEvents = new Map();
|
|
@@ -210,7 +210,7 @@ var NativeDocument = (function (exports) {
|
|
|
210
210
|
try{
|
|
211
211
|
callback.call(plugin, ...data);
|
|
212
212
|
} catch (error) {
|
|
213
|
-
DebugManager.error('Plugin Manager', `Error in plugin ${plugin.$name} for event ${eventName}`, error);
|
|
213
|
+
DebugManager$1.error('Plugin Manager', `Error in plugin ${plugin.$name} for event ${eventName}`, error);
|
|
214
214
|
}
|
|
215
215
|
}
|
|
216
216
|
}
|
|
@@ -219,7 +219,7 @@ var NativeDocument = (function (exports) {
|
|
|
219
219
|
}());
|
|
220
220
|
}
|
|
221
221
|
|
|
222
|
-
var PluginsManager = PluginsManager
|
|
222
|
+
var PluginsManager$1 = PluginsManager;
|
|
223
223
|
|
|
224
224
|
const ObservableWhen = function(observer, value) {
|
|
225
225
|
this.$target = value;
|
|
@@ -228,8 +228,8 @@ var NativeDocument = (function (exports) {
|
|
|
228
228
|
|
|
229
229
|
ObservableWhen.prototype.__$isObservableWhen = true;
|
|
230
230
|
|
|
231
|
-
ObservableWhen.prototype.subscribe = function(callback
|
|
232
|
-
return this.$observer.on(this.$target, callback
|
|
231
|
+
ObservableWhen.prototype.subscribe = function(callback) {
|
|
232
|
+
return this.$observer.on(this.$target, callback);
|
|
233
233
|
};
|
|
234
234
|
|
|
235
235
|
ObservableWhen.prototype.val = function() {
|
|
@@ -341,7 +341,7 @@ var NativeDocument = (function (exports) {
|
|
|
341
341
|
}
|
|
342
342
|
}
|
|
343
343
|
{
|
|
344
|
-
PluginsManager.emit('CreateObservable', this);
|
|
344
|
+
PluginsManager$1.emit('CreateObservable', this);
|
|
345
345
|
}
|
|
346
346
|
}
|
|
347
347
|
|
|
@@ -365,7 +365,7 @@ var NativeDocument = (function (exports) {
|
|
|
365
365
|
};
|
|
366
366
|
|
|
367
367
|
ObservableItem.prototype.triggerFirstListener = function(operations) {
|
|
368
|
-
this.$firstListener
|
|
368
|
+
this.$firstListener(this.$currentValue, this.$previousValue, operations || {});
|
|
369
369
|
};
|
|
370
370
|
|
|
371
371
|
ObservableItem.prototype.triggerListeners = function(operations) {
|
|
@@ -375,25 +375,24 @@ var NativeDocument = (function (exports) {
|
|
|
375
375
|
|
|
376
376
|
operations = operations || DEFAULT_OPERATIONS;
|
|
377
377
|
for(let i = 0, length = $listeners.length; i < length; i++) {
|
|
378
|
-
|
|
379
|
-
listener.callback($currentValue, $previousValue, operations, listener.context);
|
|
378
|
+
$listeners[i]($currentValue, $previousValue, operations);
|
|
380
379
|
}
|
|
381
380
|
};
|
|
382
381
|
|
|
383
382
|
const handleWatcherCallback = function(callbacks, value) {
|
|
384
|
-
if(callbacks
|
|
385
|
-
callbacks
|
|
383
|
+
if(typeof callbacks === "function") {
|
|
384
|
+
callbacks(value);
|
|
386
385
|
return;
|
|
387
386
|
}
|
|
388
387
|
if (callbacks.set) {
|
|
389
388
|
callbacks.set(value);
|
|
390
389
|
return;
|
|
391
390
|
}
|
|
392
|
-
callbacks.
|
|
393
|
-
callback
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
}
|
|
391
|
+
for(let i = 0, length = callbacks.length; i < length; i++) {
|
|
392
|
+
const callback = callbacks[i];
|
|
393
|
+
callback.set ? callback.set(value) : callback(value);
|
|
394
|
+
|
|
395
|
+
}
|
|
397
396
|
};
|
|
398
397
|
|
|
399
398
|
ObservableItem.prototype.triggerWatchers = function() {
|
|
@@ -405,12 +404,12 @@ var NativeDocument = (function (exports) {
|
|
|
405
404
|
const $previousValue = this.$previousValue;
|
|
406
405
|
const $currentValue = this.$currentValue;
|
|
407
406
|
|
|
408
|
-
|
|
409
|
-
|
|
407
|
+
const $currentValueCallbacks = $watchers.get($currentValue);
|
|
408
|
+
const $previousValueCallbacks = $watchers.get($previousValue);
|
|
409
|
+
if($currentValueCallbacks) {
|
|
410
410
|
handleWatcherCallback($currentValueCallbacks, true);
|
|
411
411
|
}
|
|
412
|
-
if($
|
|
413
|
-
const $previousValueCallbacks = $watchers.get($previousValue);
|
|
412
|
+
if($previousValueCallbacks) {
|
|
414
413
|
handleWatcherCallback($previousValueCallbacks, false);
|
|
415
414
|
}
|
|
416
415
|
};
|
|
@@ -422,7 +421,7 @@ var NativeDocument = (function (exports) {
|
|
|
422
421
|
|
|
423
422
|
ObservableItem.prototype.triggerWatchersAndFirstListener = function(operations) {
|
|
424
423
|
this.triggerWatchers();
|
|
425
|
-
this.
|
|
424
|
+
this.triggerFirstListener(operations);
|
|
426
425
|
};
|
|
427
426
|
|
|
428
427
|
ObservableItem.prototype.assocTrigger = function() {
|
|
@@ -470,12 +469,12 @@ var NativeDocument = (function (exports) {
|
|
|
470
469
|
this.$previousValue = this.$currentValue;
|
|
471
470
|
this.$currentValue = newValue;
|
|
472
471
|
{
|
|
473
|
-
PluginsManager.emit('ObservableBeforeChange', this);
|
|
472
|
+
PluginsManager$1.emit('ObservableBeforeChange', this);
|
|
474
473
|
}
|
|
475
474
|
this.trigger();
|
|
476
475
|
this.$previousValue = null;
|
|
477
476
|
{
|
|
478
|
-
PluginsManager.emit('ObservableAfterChange', this);
|
|
477
|
+
PluginsManager$1.emit('ObservableAfterChange', this);
|
|
479
478
|
}
|
|
480
479
|
};
|
|
481
480
|
|
|
@@ -521,54 +520,50 @@ var NativeDocument = (function (exports) {
|
|
|
521
520
|
/**
|
|
522
521
|
*
|
|
523
522
|
* @param {Function} callback
|
|
524
|
-
* @param {?Object} context
|
|
525
523
|
* @param {any} target
|
|
526
524
|
* @returns {(function(): void)}
|
|
527
525
|
*/
|
|
528
|
-
ObservableItem.prototype.subscribe = function(callback,
|
|
526
|
+
ObservableItem.prototype.subscribe = function(callback, target = null) {
|
|
529
527
|
this.$listeners = this.$listeners ?? [];
|
|
530
528
|
if (this.$isCleanedUp) {
|
|
531
|
-
DebugManager.warn('Observable subscription', '⚠️ Attempted to subscribe to a cleaned up observable.');
|
|
529
|
+
DebugManager$1.warn('Observable subscription', '⚠️ Attempted to subscribe to a cleaned up observable.');
|
|
532
530
|
return () => {};
|
|
533
531
|
}
|
|
534
532
|
if (typeof callback !== 'function') {
|
|
535
533
|
throw new NativeDocumentError('Callback must be a function');
|
|
536
534
|
}
|
|
537
535
|
|
|
538
|
-
|
|
539
|
-
const finalCallback = { callback, context };
|
|
540
|
-
this.$listeners.push(finalCallback);
|
|
536
|
+
this.$listeners.push(callback);
|
|
541
537
|
this.assocTrigger();
|
|
542
538
|
{
|
|
543
|
-
PluginsManager.emit('ObservableSubscribe', this, target);
|
|
539
|
+
PluginsManager$1.emit('ObservableSubscribe', this, target);
|
|
544
540
|
}
|
|
545
541
|
return () => {
|
|
546
|
-
this.unsubscribe(
|
|
542
|
+
this.unsubscribe(callback);
|
|
547
543
|
this.assocTrigger();
|
|
548
544
|
{
|
|
549
|
-
PluginsManager.emit('ObservableUnsubscribe', this);
|
|
545
|
+
PluginsManager$1.emit('ObservableUnsubscribe', this);
|
|
550
546
|
}
|
|
551
547
|
};
|
|
552
548
|
};
|
|
553
549
|
|
|
554
|
-
ObservableItem.prototype.on = function(value, callback
|
|
550
|
+
ObservableItem.prototype.on = function(value, callback) {
|
|
555
551
|
this.$watchers = this.$watchers ?? new Map();
|
|
556
552
|
|
|
557
553
|
let watchValueList = this.$watchers.get(value);
|
|
558
|
-
const finalCallback = { callback, context };
|
|
559
554
|
|
|
560
555
|
if(!watchValueList) {
|
|
561
|
-
this.$watchers.set(value,
|
|
556
|
+
this.$watchers.set(value, callback);
|
|
562
557
|
} else if(!Validator.isArray(watchValueList)) {
|
|
563
|
-
watchValueList = [watchValueList,
|
|
558
|
+
watchValueList = [watchValueList, callback];
|
|
564
559
|
this.$watchers.set(value, watchValueList);
|
|
565
560
|
} else {
|
|
566
|
-
watchValueList.push(
|
|
561
|
+
watchValueList.push(callback);
|
|
567
562
|
}
|
|
568
563
|
|
|
569
564
|
this.assocTrigger();
|
|
570
565
|
return () => {
|
|
571
|
-
const index = watchValueList.indexOf(
|
|
566
|
+
const index = watchValueList.indexOf(callback);
|
|
572
567
|
watchValueList?.splice(index, 1);
|
|
573
568
|
if(watchValueList.size === 1) {
|
|
574
569
|
this.$watchers.set(value, watchValueList[0]);
|
|
@@ -623,12 +618,6 @@ var NativeDocument = (function (exports) {
|
|
|
623
618
|
return new ObservableWhen(this, value);
|
|
624
619
|
};
|
|
625
620
|
|
|
626
|
-
ObservableItem.prototype.toString = function() {
|
|
627
|
-
if(!this.$memoryId) {
|
|
628
|
-
MemoryManager.register(this);
|
|
629
|
-
}
|
|
630
|
-
return '{{#ObItem::(' +this.$memoryId+ ')}}';
|
|
631
|
-
};
|
|
632
621
|
ObservableItem.prototype.equals = function(other) {
|
|
633
622
|
if(Validator.isObservable(other)) {
|
|
634
623
|
return this.$currentValue === other.$currentValue;
|
|
@@ -768,7 +757,7 @@ var NativeDocument = (function (exports) {
|
|
|
768
757
|
this.$element = element;
|
|
769
758
|
this.$observer = null;
|
|
770
759
|
{
|
|
771
|
-
PluginsManager.emit('NDElementCreated', element, this);
|
|
760
|
+
PluginsManager$1.emit('NDElementCreated', element, this);
|
|
772
761
|
}
|
|
773
762
|
}
|
|
774
763
|
|
|
@@ -889,7 +878,7 @@ var NativeDocument = (function (exports) {
|
|
|
889
878
|
}
|
|
890
879
|
{
|
|
891
880
|
if (this[name] && !this.$localExtensions.has(name)) {
|
|
892
|
-
DebugManager.warn('NDElement.extend', `Method "${name}" already exists and will be overwritten`);
|
|
881
|
+
DebugManager$1.warn('NDElement.extend', `Method "${name}" already exists and will be overwritten`);
|
|
893
882
|
}
|
|
894
883
|
this.$localExtensions.set(name, method);
|
|
895
884
|
}
|
|
@@ -923,23 +912,23 @@ var NativeDocument = (function (exports) {
|
|
|
923
912
|
const method = methods[name];
|
|
924
913
|
|
|
925
914
|
if (typeof method !== 'function') {
|
|
926
|
-
DebugManager.warn('NDElement.extend', `"${name}" is not a function, skipping`);
|
|
915
|
+
DebugManager$1.warn('NDElement.extend', `"${name}" is not a function, skipping`);
|
|
927
916
|
continue;
|
|
928
917
|
}
|
|
929
918
|
|
|
930
919
|
if (protectedMethods.has(name)) {
|
|
931
|
-
DebugManager.error('NDElement.extend', `Cannot override protected method "${name}"`);
|
|
920
|
+
DebugManager$1.error('NDElement.extend', `Cannot override protected method "${name}"`);
|
|
932
921
|
throw new NativeDocumentError(`Cannot override protected method "${name}"`);
|
|
933
922
|
}
|
|
934
923
|
|
|
935
924
|
if (NDElement.prototype[name]) {
|
|
936
|
-
DebugManager.warn('NDElement.extend', `Overwriting existing prototype method "${name}"`);
|
|
925
|
+
DebugManager$1.warn('NDElement.extend', `Overwriting existing prototype method "${name}"`);
|
|
937
926
|
}
|
|
938
927
|
|
|
939
928
|
NDElement.prototype[name] = method;
|
|
940
929
|
}
|
|
941
930
|
{
|
|
942
|
-
PluginsManager.emit('NDElementExtended', methods);
|
|
931
|
+
PluginsManager$1.emit('NDElementExtended', methods);
|
|
943
932
|
}
|
|
944
933
|
|
|
945
934
|
return NDElement;
|
|
@@ -1092,7 +1081,7 @@ var NativeDocument = (function (exports) {
|
|
|
1092
1081
|
const foundReserved = Object.keys(attributes).filter(key => reserved.includes(key));
|
|
1093
1082
|
|
|
1094
1083
|
if (foundReserved.length > 0) {
|
|
1095
|
-
DebugManager.warn('Validator', `Reserved attributes found: ${foundReserved.join(', ')}`);
|
|
1084
|
+
DebugManager$1.warn('Validator', `Reserved attributes found: ${foundReserved.join(', ')}`);
|
|
1096
1085
|
}
|
|
1097
1086
|
|
|
1098
1087
|
return attributes;
|
|
@@ -1140,7 +1129,7 @@ var NativeDocument = (function (exports) {
|
|
|
1140
1129
|
anchorFragment.appendChild = function(child, before = null) {
|
|
1141
1130
|
const parent = anchorEnd.parentNode;
|
|
1142
1131
|
if(!parent) {
|
|
1143
|
-
DebugManager.error('Anchor', 'Anchor : parent not found', child);
|
|
1132
|
+
DebugManager$1.error('Anchor', 'Anchor : parent not found', child);
|
|
1144
1133
|
return;
|
|
1145
1134
|
}
|
|
1146
1135
|
before = before ?? anchorEnd;
|
|
@@ -1354,9 +1343,6 @@ var NativeDocument = (function (exports) {
|
|
|
1354
1343
|
setInterval(() => MemoryManager.cleanObservables(threshold), interval);
|
|
1355
1344
|
};
|
|
1356
1345
|
|
|
1357
|
-
const handleElementAttributeClass = function(shouldAdd, _, __, context) {
|
|
1358
|
-
context.element.classes.toggle(context.className, shouldAdd);
|
|
1359
|
-
};
|
|
1360
1346
|
/**
|
|
1361
1347
|
*
|
|
1362
1348
|
* @param {HTMLElement} element
|
|
@@ -1364,19 +1350,17 @@ var NativeDocument = (function (exports) {
|
|
|
1364
1350
|
*/
|
|
1365
1351
|
function bindClassAttribute(element, data) {
|
|
1366
1352
|
const classNames = Object.keys(data);
|
|
1367
|
-
|
|
1368
1353
|
for(let i = 0, length = classNames.length; i < length; i++) {
|
|
1369
1354
|
const className = classNames[i];
|
|
1370
1355
|
const value = data[className];
|
|
1371
1356
|
if(value.__$isObservable) {
|
|
1372
1357
|
element.classes.toggle(className, value.val());
|
|
1373
|
-
value.subscribe(
|
|
1374
|
-
// value.subscribe((shouldAdd) => element.classes.toggle(className, shouldAdd));
|
|
1358
|
+
value.subscribe((shouldAdd) => element.classes.toggle(className, shouldAdd));
|
|
1375
1359
|
continue;
|
|
1376
1360
|
}
|
|
1377
1361
|
if(value.__$isObservableWhen) {
|
|
1378
1362
|
element.classes.toggle(className, value.isMath());
|
|
1379
|
-
value.subscribe(
|
|
1363
|
+
value.subscribe((shouldAdd) => element.classes.toggle(className, shouldAdd));
|
|
1380
1364
|
continue;
|
|
1381
1365
|
}
|
|
1382
1366
|
if(value.$hydrate) {
|
|
@@ -1385,6 +1369,7 @@ var NativeDocument = (function (exports) {
|
|
|
1385
1369
|
}
|
|
1386
1370
|
element.classes.toggle(className, value);
|
|
1387
1371
|
}
|
|
1372
|
+
data = null;
|
|
1388
1373
|
}
|
|
1389
1374
|
|
|
1390
1375
|
/**
|
|
@@ -1415,8 +1400,7 @@ var NativeDocument = (function (exports) {
|
|
|
1415
1400
|
function bindBooleanAttribute(element, attributeName, value) {
|
|
1416
1401
|
const isObservable = value.__$isObservable;
|
|
1417
1402
|
const defaultValue = isObservable? value.val() : value;
|
|
1418
|
-
|
|
1419
|
-
if(isBoolValue) {
|
|
1403
|
+
if(Validator.isBoolean(defaultValue)) {
|
|
1420
1404
|
element[attributeName] = defaultValue;
|
|
1421
1405
|
}
|
|
1422
1406
|
else {
|
|
@@ -1424,13 +1408,13 @@ var NativeDocument = (function (exports) {
|
|
|
1424
1408
|
}
|
|
1425
1409
|
if(isObservable) {
|
|
1426
1410
|
if(attributeName === 'checked') {
|
|
1427
|
-
if(
|
|
1411
|
+
if(typeof defaultValue === 'boolean') {
|
|
1428
1412
|
element.addEventListener('input', () => value.set(element[attributeName]));
|
|
1429
|
-
value.subscribe((newValue) => element[attributeName] = newValue);
|
|
1430
|
-
return;
|
|
1431
1413
|
}
|
|
1432
|
-
|
|
1433
|
-
|
|
1414
|
+
else {
|
|
1415
|
+
element.addEventListener('input', () => value.set(element.value));
|
|
1416
|
+
}
|
|
1417
|
+
value.subscribe((newValue) => element[attributeName] = newValue);
|
|
1434
1418
|
return;
|
|
1435
1419
|
}
|
|
1436
1420
|
value.subscribe((newValue) => element[attributeName] = (newValue === element.value));
|
|
@@ -1445,14 +1429,14 @@ var NativeDocument = (function (exports) {
|
|
|
1445
1429
|
* @param {Observable} value
|
|
1446
1430
|
*/
|
|
1447
1431
|
function bindAttributeWithObservable(element, attributeName, value) {
|
|
1432
|
+
const applyValue = attributeName === 'value' ? (newValue) => element.value = newValue : (newValue) => element.setAttribute(attributeName, newValue);
|
|
1433
|
+
value.subscribe(applyValue);
|
|
1434
|
+
|
|
1448
1435
|
if(attributeName === 'value') {
|
|
1449
|
-
value.subscribe((newValue) => element.value = newValue);
|
|
1450
1436
|
element.value = value.val();
|
|
1451
1437
|
element.addEventListener('input', () => value.set(element.value));
|
|
1452
1438
|
return;
|
|
1453
1439
|
}
|
|
1454
|
-
|
|
1455
|
-
value.subscribe((newValue) => element.setAttribute(attributeName, newValue));
|
|
1456
1440
|
element.setAttribute(attributeName, value.val());
|
|
1457
1441
|
}
|
|
1458
1442
|
|
|
@@ -1463,13 +1447,11 @@ var NativeDocument = (function (exports) {
|
|
|
1463
1447
|
*/
|
|
1464
1448
|
function AttributesWrapper(element, attributes) {
|
|
1465
1449
|
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
}
|
|
1469
|
-
const attributeNames = Object.keys(attributes);
|
|
1450
|
+
Validator.validateAttributes(attributes);
|
|
1451
|
+
const attributesKeys = Object.keys(attributes);
|
|
1470
1452
|
|
|
1471
|
-
for(let i = 0, length =
|
|
1472
|
-
const originalAttributeName =
|
|
1453
|
+
for(let i = 0, length = attributesKeys.length; i < length; i++) {
|
|
1454
|
+
const originalAttributeName = attributesKeys[i];
|
|
1473
1455
|
const attributeName = originalAttributeName.toLowerCase();
|
|
1474
1456
|
let value = attributes[originalAttributeName];
|
|
1475
1457
|
if(value == null) {
|
|
@@ -1494,10 +1476,6 @@ var NativeDocument = (function (exports) {
|
|
|
1494
1476
|
continue;
|
|
1495
1477
|
}
|
|
1496
1478
|
|
|
1497
|
-
if(attributeName === 'value') {
|
|
1498
|
-
element.value = value;
|
|
1499
|
-
continue;
|
|
1500
|
-
}
|
|
1501
1479
|
element.setAttribute(attributeName, value);
|
|
1502
1480
|
}
|
|
1503
1481
|
return element;
|
|
@@ -1548,7 +1526,7 @@ var NativeDocument = (function (exports) {
|
|
|
1548
1526
|
Function.prototype.toNdElement = function () {
|
|
1549
1527
|
const child = this;
|
|
1550
1528
|
{
|
|
1551
|
-
PluginsManager.emit('BeforeProcessComponent', child);
|
|
1529
|
+
PluginsManager$1.emit('BeforeProcessComponent', child);
|
|
1552
1530
|
}
|
|
1553
1531
|
return ElementCreator.getChild(child());
|
|
1554
1532
|
};
|
|
@@ -1654,14 +1632,14 @@ var NativeDocument = (function (exports) {
|
|
|
1654
1632
|
processChildren(children, parent) {
|
|
1655
1633
|
if(children === null) return;
|
|
1656
1634
|
{
|
|
1657
|
-
PluginsManager.emit('BeforeProcessChildren', parent);
|
|
1635
|
+
PluginsManager$1.emit('BeforeProcessChildren', parent);
|
|
1658
1636
|
}
|
|
1659
1637
|
let child = this.getChild(children);
|
|
1660
1638
|
if(child) {
|
|
1661
1639
|
parent.appendChild(child);
|
|
1662
1640
|
}
|
|
1663
1641
|
{
|
|
1664
|
-
PluginsManager.emit('AfterProcessChildren', parent);
|
|
1642
|
+
PluginsManager$1.emit('AfterProcessChildren', parent);
|
|
1665
1643
|
}
|
|
1666
1644
|
},
|
|
1667
1645
|
getChild(child) {
|
|
@@ -2886,7 +2864,7 @@ var NativeDocument = (function (exports) {
|
|
|
2886
2864
|
|
|
2887
2865
|
ObservableItem.call(this, target, configs);
|
|
2888
2866
|
{
|
|
2889
|
-
PluginsManager.emit('CreateObservableArray', this);
|
|
2867
|
+
PluginsManager$1.emit('CreateObservableArray', this);
|
|
2890
2868
|
}
|
|
2891
2869
|
};
|
|
2892
2870
|
|
|
@@ -3287,7 +3265,7 @@ var NativeDocument = (function (exports) {
|
|
|
3287
3265
|
const observable = new ObservableItem(initialValue);
|
|
3288
3266
|
const updatedValue = nextTick(() => observable.set(callback()));
|
|
3289
3267
|
{
|
|
3290
|
-
PluginsManager.emit('CreateObservableComputed', observable, dependencies);
|
|
3268
|
+
PluginsManager$1.emit('CreateObservableComputed', observable, dependencies);
|
|
3291
3269
|
}
|
|
3292
3270
|
|
|
3293
3271
|
if(Validator.isFunction(dependencies)) {
|
|
@@ -3447,7 +3425,7 @@ var NativeDocument = (function (exports) {
|
|
|
3447
3425
|
}
|
|
3448
3426
|
cache.set(keyId, { keyId, isNew: true, child: new WeakRef(child), indexObserver});
|
|
3449
3427
|
} catch (e) {
|
|
3450
|
-
DebugManager.error('ForEach', `Error creating element for key ${keyId}` , e);
|
|
3428
|
+
DebugManager$1.error('ForEach', `Error creating element for key ${keyId}` , e);
|
|
3451
3429
|
throw e;
|
|
3452
3430
|
}
|
|
3453
3431
|
return keyId;
|
|
@@ -3793,7 +3771,7 @@ var NativeDocument = (function (exports) {
|
|
|
3793
3771
|
*/
|
|
3794
3772
|
const ShowIf = function(condition, child, { comment = null, shouldKeepInCache = true} = {}) {
|
|
3795
3773
|
if(!(Validator.isObservable(condition)) && !Validator.isObservableWhenResult(condition)) {
|
|
3796
|
-
return DebugManager.warn('ShowIf', "ShowIf : condition must be an Observable / "+comment, condition);
|
|
3774
|
+
return DebugManager$1.warn('ShowIf', "ShowIf : condition must be an Observable / "+comment, condition);
|
|
3797
3775
|
}
|
|
3798
3776
|
const element = Anchor('Show if : '+(comment || ''));
|
|
3799
3777
|
|
|
@@ -4580,7 +4558,7 @@ var NativeDocument = (function (exports) {
|
|
|
4580
4558
|
window.history.pushState({ name: route.name(), params, path}, route.name() || path , path);
|
|
4581
4559
|
this.handleRouteChange(route, params, query, path);
|
|
4582
4560
|
} catch (e) {
|
|
4583
|
-
DebugManager.error('HistoryRouter', 'Error in pushState', e);
|
|
4561
|
+
DebugManager$1.error('HistoryRouter', 'Error in pushState', e);
|
|
4584
4562
|
}
|
|
4585
4563
|
};
|
|
4586
4564
|
/**
|
|
@@ -4593,7 +4571,7 @@ var NativeDocument = (function (exports) {
|
|
|
4593
4571
|
window.history.replaceState({ name: route.name(), params, path}, route.name() || path , path);
|
|
4594
4572
|
this.handleRouteChange(route, params, {}, path);
|
|
4595
4573
|
} catch(e) {
|
|
4596
|
-
DebugManager.error('HistoryRouter', 'Error in replaceState', e);
|
|
4574
|
+
DebugManager$1.error('HistoryRouter', 'Error in replaceState', e);
|
|
4597
4575
|
}
|
|
4598
4576
|
};
|
|
4599
4577
|
this.forward = function() {
|
|
@@ -4620,7 +4598,7 @@ var NativeDocument = (function (exports) {
|
|
|
4620
4598
|
}
|
|
4621
4599
|
this.handleRouteChange(route, params, query, path);
|
|
4622
4600
|
} catch(e) {
|
|
4623
|
-
DebugManager.error('HistoryRouter', 'Error in popstate event', e);
|
|
4601
|
+
DebugManager$1.error('HistoryRouter', 'Error in popstate event', e);
|
|
4624
4602
|
}
|
|
4625
4603
|
});
|
|
4626
4604
|
const { route, params, query, path } = this.resolve(defaultPath || (window.location.pathname+window.location.search));
|
|
@@ -4845,7 +4823,7 @@ var NativeDocument = (function (exports) {
|
|
|
4845
4823
|
listener(request);
|
|
4846
4824
|
next && next(request);
|
|
4847
4825
|
} catch (e) {
|
|
4848
|
-
DebugManager.warn('Route Listener', 'Error in listener:', e);
|
|
4826
|
+
DebugManager$1.warn('Route Listener', 'Error in listener:', e);
|
|
4849
4827
|
}
|
|
4850
4828
|
}
|
|
4851
4829
|
};
|
|
@@ -5004,7 +4982,7 @@ var NativeDocument = (function (exports) {
|
|
|
5004
4982
|
*/
|
|
5005
4983
|
Router.create = function(options, callback) {
|
|
5006
4984
|
if(!Validator.isFunction(callback)) {
|
|
5007
|
-
DebugManager.error('Router', 'Callback must be a function', e);
|
|
4985
|
+
DebugManager$1.error('Router', 'Callback must be a function', e);
|
|
5008
4986
|
throw new RouterError('Callback must be a function');
|
|
5009
4987
|
}
|
|
5010
4988
|
const router = new Router(options);
|
|
@@ -5188,7 +5166,7 @@ var NativeDocument = (function (exports) {
|
|
|
5188
5166
|
exports.HtmlElementWrapper = HtmlElementWrapper;
|
|
5189
5167
|
exports.NDElement = NDElement;
|
|
5190
5168
|
exports.Observable = Observable;
|
|
5191
|
-
exports.PluginsManager = PluginsManager;
|
|
5169
|
+
exports.PluginsManager = PluginsManager$1;
|
|
5192
5170
|
exports.SingletonView = SingletonView;
|
|
5193
5171
|
exports.Store = Store;
|
|
5194
5172
|
exports.TemplateCloner = TemplateCloner;
|