native-document 1.0.88 → 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 +23 -37
- package/dist/native-document.dev.js +58 -76
- 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/ObservableItem.js +11 -16
- package/src/core/utils/callback-handler.js +21 -0
- package/src/core/wrappers/AttributesWrapper.js +13 -13
- package/src/core/wrappers/prototypes/bind-class-extensions.js +2 -2
|
@@ -518,7 +518,6 @@ var NativeComponents = (function (exports) {
|
|
|
518
518
|
|
|
519
519
|
operations = operations || DEFAULT_OPERATIONS;
|
|
520
520
|
for(let i = 0, length = $listeners.length; i < length; i++) {
|
|
521
|
-
$listeners[i];
|
|
522
521
|
$listeners[i]($currentValue, $previousValue, operations);
|
|
523
522
|
}
|
|
524
523
|
};
|
|
@@ -532,9 +531,11 @@ var NativeComponents = (function (exports) {
|
|
|
532
531
|
callbacks.set(value);
|
|
533
532
|
return;
|
|
534
533
|
}
|
|
535
|
-
callbacks.
|
|
534
|
+
for(let i = 0, length = callbacks.length; i < length; i++) {
|
|
535
|
+
const callback = callbacks[i];
|
|
536
536
|
callback.set ? callback.set(value) : callback(value);
|
|
537
|
-
|
|
537
|
+
|
|
538
|
+
}
|
|
538
539
|
};
|
|
539
540
|
|
|
540
541
|
ObservableItem.prototype.triggerWatchers = function() {
|
|
@@ -546,12 +547,12 @@ var NativeComponents = (function (exports) {
|
|
|
546
547
|
const $previousValue = this.$previousValue;
|
|
547
548
|
const $currentValue = this.$currentValue;
|
|
548
549
|
|
|
549
|
-
|
|
550
|
-
|
|
550
|
+
const $currentValueCallbacks = $watchers.get($currentValue);
|
|
551
|
+
const $previousValueCallbacks = $watchers.get($previousValue);
|
|
552
|
+
if($currentValueCallbacks) {
|
|
551
553
|
handleWatcherCallback($currentValueCallbacks, true);
|
|
552
554
|
}
|
|
553
|
-
if($
|
|
554
|
-
const $previousValueCallbacks = $watchers.get($previousValue);
|
|
555
|
+
if($previousValueCallbacks) {
|
|
555
556
|
handleWatcherCallback($previousValueCallbacks, false);
|
|
556
557
|
}
|
|
557
558
|
};
|
|
@@ -563,7 +564,7 @@ var NativeComponents = (function (exports) {
|
|
|
563
564
|
|
|
564
565
|
ObservableItem.prototype.triggerWatchersAndFirstListener = function(operations) {
|
|
565
566
|
this.triggerWatchers();
|
|
566
|
-
this.
|
|
567
|
+
this.triggerFirstListener(operations);
|
|
567
568
|
};
|
|
568
569
|
|
|
569
570
|
ObservableItem.prototype.assocTrigger = function() {
|
|
@@ -685,9 +686,8 @@ var NativeComponents = (function (exports) {
|
|
|
685
686
|
if(!watchValueList) {
|
|
686
687
|
this.$watchers.set(value, callback);
|
|
687
688
|
} else if(!Validator.isArray(watchValueList)) {
|
|
688
|
-
watchValueList = [watchValueList];
|
|
689
|
+
watchValueList = [watchValueList, callback];
|
|
689
690
|
this.$watchers.set(value, watchValueList);
|
|
690
|
-
return;
|
|
691
691
|
} else {
|
|
692
692
|
watchValueList.push(callback);
|
|
693
693
|
}
|
|
@@ -749,12 +749,6 @@ var NativeComponents = (function (exports) {
|
|
|
749
749
|
return new ObservableWhen(this, value);
|
|
750
750
|
};
|
|
751
751
|
|
|
752
|
-
ObservableItem.prototype.toString = function() {
|
|
753
|
-
if(!this.$memoryId) {
|
|
754
|
-
MemoryManager.register(this);
|
|
755
|
-
}
|
|
756
|
-
return '{{#ObItem::(' +this.$memoryId+ ')}}';
|
|
757
|
-
};
|
|
758
752
|
ObservableItem.prototype.equals = function(other) {
|
|
759
753
|
if(Validator.isObservable(other)) {
|
|
760
754
|
return this.$currentValue === other.$currentValue;
|
|
@@ -1426,36 +1420,24 @@ var NativeComponents = (function (exports) {
|
|
|
1426
1420
|
setInterval(() => MemoryManager.cleanObservables(threshold), interval);
|
|
1427
1421
|
};
|
|
1428
1422
|
|
|
1429
|
-
ObservableItem.prototype.bindNdClass = function(element, className) {
|
|
1430
|
-
element.classes.toggle(className, this.val());
|
|
1431
|
-
this.subscribe(toggleElementClass.bind(null, element, className));
|
|
1432
|
-
};
|
|
1433
|
-
|
|
1434
|
-
ObservableWhen.prototype.bindNdClass = function(element, className) {
|
|
1435
|
-
element.classes.toggle(className, this.isMath());
|
|
1436
|
-
this.subscribe(toggleElementClass.bind(null, element, className));
|
|
1437
|
-
};
|
|
1438
|
-
|
|
1439
|
-
function toggleElementClass(element, className, shouldAdd) {
|
|
1440
|
-
element.classes.toggle(className, shouldAdd);
|
|
1441
|
-
}
|
|
1442
|
-
|
|
1443
1423
|
/**
|
|
1444
1424
|
*
|
|
1445
1425
|
* @param {HTMLElement} element
|
|
1446
1426
|
* @param {Object} data
|
|
1447
1427
|
*/
|
|
1448
1428
|
function bindClassAttribute(element, data) {
|
|
1449
|
-
|
|
1429
|
+
const classNames = Object.keys(data);
|
|
1430
|
+
for(let i = 0, length = classNames.length; i < length; i++) {
|
|
1431
|
+
const className = classNames[i];
|
|
1450
1432
|
const value = data[className];
|
|
1451
1433
|
if(value.__$isObservable) {
|
|
1452
1434
|
element.classes.toggle(className, value.val());
|
|
1453
|
-
value.subscribe(
|
|
1435
|
+
value.subscribe((shouldAdd) => element.classes.toggle(className, shouldAdd));
|
|
1454
1436
|
continue;
|
|
1455
1437
|
}
|
|
1456
1438
|
if(value.__$isObservableWhen) {
|
|
1457
1439
|
element.classes.toggle(className, value.isMath());
|
|
1458
|
-
value.subscribe(
|
|
1440
|
+
value.subscribe((shouldAdd) => element.classes.toggle(className, shouldAdd));
|
|
1459
1441
|
continue;
|
|
1460
1442
|
}
|
|
1461
1443
|
if(value.$hydrate) {
|
|
@@ -1473,7 +1455,9 @@ var NativeComponents = (function (exports) {
|
|
|
1473
1455
|
* @param {Object} data
|
|
1474
1456
|
*/
|
|
1475
1457
|
function bindStyleAttribute(element, data) {
|
|
1476
|
-
|
|
1458
|
+
const keys = Object.keys(data);
|
|
1459
|
+
for(let i = 0, length = keys.length; i < length; i++) {
|
|
1460
|
+
const styleName = keys[i];
|
|
1477
1461
|
const value = data[styleName];
|
|
1478
1462
|
if(value.__$isObservable) {
|
|
1479
1463
|
element.style[styleName] = value.val();
|
|
@@ -1539,10 +1523,12 @@ var NativeComponents = (function (exports) {
|
|
|
1539
1523
|
* @param {Object} attributes
|
|
1540
1524
|
*/
|
|
1541
1525
|
function AttributesWrapper(element, attributes) {
|
|
1526
|
+
const attributesKeys = Object.keys(attributes);
|
|
1542
1527
|
|
|
1543
|
-
for(let
|
|
1544
|
-
const
|
|
1545
|
-
|
|
1528
|
+
for(let i = 0, length = attributesKeys.length; i < length; i++) {
|
|
1529
|
+
const originalAttributeName = attributesKeys[i];
|
|
1530
|
+
const attributeName = originalAttributeName.toLowerCase();
|
|
1531
|
+
let value = attributes[originalAttributeName];
|
|
1546
1532
|
if(value == null) {
|
|
1547
1533
|
continue;
|
|
1548
1534
|
}
|
|
@@ -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
|
};
|
|
@@ -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;
|
|
@@ -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
|
|
|
@@ -375,7 +375,6 @@ 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
|
-
$listeners[i];
|
|
379
378
|
$listeners[i]($currentValue, $previousValue, operations);
|
|
380
379
|
}
|
|
381
380
|
};
|
|
@@ -389,9 +388,11 @@ var NativeDocument = (function (exports) {
|
|
|
389
388
|
callbacks.set(value);
|
|
390
389
|
return;
|
|
391
390
|
}
|
|
392
|
-
callbacks.
|
|
391
|
+
for(let i = 0, length = callbacks.length; i < length; i++) {
|
|
392
|
+
const callback = callbacks[i];
|
|
393
393
|
callback.set ? callback.set(value) : callback(value);
|
|
394
|
-
|
|
394
|
+
|
|
395
|
+
}
|
|
395
396
|
};
|
|
396
397
|
|
|
397
398
|
ObservableItem.prototype.triggerWatchers = function() {
|
|
@@ -403,12 +404,12 @@ var NativeDocument = (function (exports) {
|
|
|
403
404
|
const $previousValue = this.$previousValue;
|
|
404
405
|
const $currentValue = this.$currentValue;
|
|
405
406
|
|
|
406
|
-
|
|
407
|
-
|
|
407
|
+
const $currentValueCallbacks = $watchers.get($currentValue);
|
|
408
|
+
const $previousValueCallbacks = $watchers.get($previousValue);
|
|
409
|
+
if($currentValueCallbacks) {
|
|
408
410
|
handleWatcherCallback($currentValueCallbacks, true);
|
|
409
411
|
}
|
|
410
|
-
if($
|
|
411
|
-
const $previousValueCallbacks = $watchers.get($previousValue);
|
|
412
|
+
if($previousValueCallbacks) {
|
|
412
413
|
handleWatcherCallback($previousValueCallbacks, false);
|
|
413
414
|
}
|
|
414
415
|
};
|
|
@@ -420,7 +421,7 @@ var NativeDocument = (function (exports) {
|
|
|
420
421
|
|
|
421
422
|
ObservableItem.prototype.triggerWatchersAndFirstListener = function(operations) {
|
|
422
423
|
this.triggerWatchers();
|
|
423
|
-
this.
|
|
424
|
+
this.triggerFirstListener(operations);
|
|
424
425
|
};
|
|
425
426
|
|
|
426
427
|
ObservableItem.prototype.assocTrigger = function() {
|
|
@@ -468,12 +469,12 @@ var NativeDocument = (function (exports) {
|
|
|
468
469
|
this.$previousValue = this.$currentValue;
|
|
469
470
|
this.$currentValue = newValue;
|
|
470
471
|
{
|
|
471
|
-
PluginsManager.emit('ObservableBeforeChange', this);
|
|
472
|
+
PluginsManager$1.emit('ObservableBeforeChange', this);
|
|
472
473
|
}
|
|
473
474
|
this.trigger();
|
|
474
475
|
this.$previousValue = null;
|
|
475
476
|
{
|
|
476
|
-
PluginsManager.emit('ObservableAfterChange', this);
|
|
477
|
+
PluginsManager$1.emit('ObservableAfterChange', this);
|
|
477
478
|
}
|
|
478
479
|
};
|
|
479
480
|
|
|
@@ -525,7 +526,7 @@ var NativeDocument = (function (exports) {
|
|
|
525
526
|
ObservableItem.prototype.subscribe = function(callback, target = null) {
|
|
526
527
|
this.$listeners = this.$listeners ?? [];
|
|
527
528
|
if (this.$isCleanedUp) {
|
|
528
|
-
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.');
|
|
529
530
|
return () => {};
|
|
530
531
|
}
|
|
531
532
|
if (typeof callback !== 'function') {
|
|
@@ -535,13 +536,13 @@ var NativeDocument = (function (exports) {
|
|
|
535
536
|
this.$listeners.push(callback);
|
|
536
537
|
this.assocTrigger();
|
|
537
538
|
{
|
|
538
|
-
PluginsManager.emit('ObservableSubscribe', this, target);
|
|
539
|
+
PluginsManager$1.emit('ObservableSubscribe', this, target);
|
|
539
540
|
}
|
|
540
541
|
return () => {
|
|
541
542
|
this.unsubscribe(callback);
|
|
542
543
|
this.assocTrigger();
|
|
543
544
|
{
|
|
544
|
-
PluginsManager.emit('ObservableUnsubscribe', this);
|
|
545
|
+
PluginsManager$1.emit('ObservableUnsubscribe', this);
|
|
545
546
|
}
|
|
546
547
|
};
|
|
547
548
|
};
|
|
@@ -554,9 +555,8 @@ var NativeDocument = (function (exports) {
|
|
|
554
555
|
if(!watchValueList) {
|
|
555
556
|
this.$watchers.set(value, callback);
|
|
556
557
|
} else if(!Validator.isArray(watchValueList)) {
|
|
557
|
-
watchValueList = [watchValueList];
|
|
558
|
+
watchValueList = [watchValueList, callback];
|
|
558
559
|
this.$watchers.set(value, watchValueList);
|
|
559
|
-
return;
|
|
560
560
|
} else {
|
|
561
561
|
watchValueList.push(callback);
|
|
562
562
|
}
|
|
@@ -618,12 +618,6 @@ var NativeDocument = (function (exports) {
|
|
|
618
618
|
return new ObservableWhen(this, value);
|
|
619
619
|
};
|
|
620
620
|
|
|
621
|
-
ObservableItem.prototype.toString = function() {
|
|
622
|
-
if(!this.$memoryId) {
|
|
623
|
-
MemoryManager.register(this);
|
|
624
|
-
}
|
|
625
|
-
return '{{#ObItem::(' +this.$memoryId+ ')}}';
|
|
626
|
-
};
|
|
627
621
|
ObservableItem.prototype.equals = function(other) {
|
|
628
622
|
if(Validator.isObservable(other)) {
|
|
629
623
|
return this.$currentValue === other.$currentValue;
|
|
@@ -763,7 +757,7 @@ var NativeDocument = (function (exports) {
|
|
|
763
757
|
this.$element = element;
|
|
764
758
|
this.$observer = null;
|
|
765
759
|
{
|
|
766
|
-
PluginsManager.emit('NDElementCreated', element, this);
|
|
760
|
+
PluginsManager$1.emit('NDElementCreated', element, this);
|
|
767
761
|
}
|
|
768
762
|
}
|
|
769
763
|
|
|
@@ -884,7 +878,7 @@ var NativeDocument = (function (exports) {
|
|
|
884
878
|
}
|
|
885
879
|
{
|
|
886
880
|
if (this[name] && !this.$localExtensions.has(name)) {
|
|
887
|
-
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`);
|
|
888
882
|
}
|
|
889
883
|
this.$localExtensions.set(name, method);
|
|
890
884
|
}
|
|
@@ -918,23 +912,23 @@ var NativeDocument = (function (exports) {
|
|
|
918
912
|
const method = methods[name];
|
|
919
913
|
|
|
920
914
|
if (typeof method !== 'function') {
|
|
921
|
-
DebugManager.warn('NDElement.extend', `"${name}" is not a function, skipping`);
|
|
915
|
+
DebugManager$1.warn('NDElement.extend', `"${name}" is not a function, skipping`);
|
|
922
916
|
continue;
|
|
923
917
|
}
|
|
924
918
|
|
|
925
919
|
if (protectedMethods.has(name)) {
|
|
926
|
-
DebugManager.error('NDElement.extend', `Cannot override protected method "${name}"`);
|
|
920
|
+
DebugManager$1.error('NDElement.extend', `Cannot override protected method "${name}"`);
|
|
927
921
|
throw new NativeDocumentError(`Cannot override protected method "${name}"`);
|
|
928
922
|
}
|
|
929
923
|
|
|
930
924
|
if (NDElement.prototype[name]) {
|
|
931
|
-
DebugManager.warn('NDElement.extend', `Overwriting existing prototype method "${name}"`);
|
|
925
|
+
DebugManager$1.warn('NDElement.extend', `Overwriting existing prototype method "${name}"`);
|
|
932
926
|
}
|
|
933
927
|
|
|
934
928
|
NDElement.prototype[name] = method;
|
|
935
929
|
}
|
|
936
930
|
{
|
|
937
|
-
PluginsManager.emit('NDElementExtended', methods);
|
|
931
|
+
PluginsManager$1.emit('NDElementExtended', methods);
|
|
938
932
|
}
|
|
939
933
|
|
|
940
934
|
return NDElement;
|
|
@@ -1087,7 +1081,7 @@ var NativeDocument = (function (exports) {
|
|
|
1087
1081
|
const foundReserved = Object.keys(attributes).filter(key => reserved.includes(key));
|
|
1088
1082
|
|
|
1089
1083
|
if (foundReserved.length > 0) {
|
|
1090
|
-
DebugManager.warn('Validator', `Reserved attributes found: ${foundReserved.join(', ')}`);
|
|
1084
|
+
DebugManager$1.warn('Validator', `Reserved attributes found: ${foundReserved.join(', ')}`);
|
|
1091
1085
|
}
|
|
1092
1086
|
|
|
1093
1087
|
return attributes;
|
|
@@ -1135,7 +1129,7 @@ var NativeDocument = (function (exports) {
|
|
|
1135
1129
|
anchorFragment.appendChild = function(child, before = null) {
|
|
1136
1130
|
const parent = anchorEnd.parentNode;
|
|
1137
1131
|
if(!parent) {
|
|
1138
|
-
DebugManager.error('Anchor', 'Anchor : parent not found', child);
|
|
1132
|
+
DebugManager$1.error('Anchor', 'Anchor : parent not found', child);
|
|
1139
1133
|
return;
|
|
1140
1134
|
}
|
|
1141
1135
|
before = before ?? anchorEnd;
|
|
@@ -1349,40 +1343,24 @@ var NativeDocument = (function (exports) {
|
|
|
1349
1343
|
setInterval(() => MemoryManager.cleanObservables(threshold), interval);
|
|
1350
1344
|
};
|
|
1351
1345
|
|
|
1352
|
-
ObservableItem.prototype.bindNdClass = function(element, className) {
|
|
1353
|
-
element.classes.toggle(className, this.val());
|
|
1354
|
-
this.subscribe(toggleElementClass.bind(null, element, className));
|
|
1355
|
-
};
|
|
1356
|
-
|
|
1357
|
-
ObservableWhen.prototype.bindNdClass = function(element, className) {
|
|
1358
|
-
element.classes.toggle(className, this.isMath());
|
|
1359
|
-
this.subscribe(toggleElementClass.bind(null, element, className));
|
|
1360
|
-
};
|
|
1361
|
-
|
|
1362
|
-
TemplateBinding.prototype.bindNdClass = function(element, className) {
|
|
1363
|
-
this.$hydrate(element, className);
|
|
1364
|
-
};
|
|
1365
|
-
|
|
1366
|
-
function toggleElementClass(element, className, shouldAdd) {
|
|
1367
|
-
element.classes.toggle(className, shouldAdd);
|
|
1368
|
-
}
|
|
1369
|
-
|
|
1370
1346
|
/**
|
|
1371
1347
|
*
|
|
1372
1348
|
* @param {HTMLElement} element
|
|
1373
1349
|
* @param {Object} data
|
|
1374
1350
|
*/
|
|
1375
1351
|
function bindClassAttribute(element, data) {
|
|
1376
|
-
|
|
1352
|
+
const classNames = Object.keys(data);
|
|
1353
|
+
for(let i = 0, length = classNames.length; i < length; i++) {
|
|
1354
|
+
const className = classNames[i];
|
|
1377
1355
|
const value = data[className];
|
|
1378
1356
|
if(value.__$isObservable) {
|
|
1379
1357
|
element.classes.toggle(className, value.val());
|
|
1380
|
-
value.subscribe(
|
|
1358
|
+
value.subscribe((shouldAdd) => element.classes.toggle(className, shouldAdd));
|
|
1381
1359
|
continue;
|
|
1382
1360
|
}
|
|
1383
1361
|
if(value.__$isObservableWhen) {
|
|
1384
1362
|
element.classes.toggle(className, value.isMath());
|
|
1385
|
-
value.subscribe(
|
|
1363
|
+
value.subscribe((shouldAdd) => element.classes.toggle(className, shouldAdd));
|
|
1386
1364
|
continue;
|
|
1387
1365
|
}
|
|
1388
1366
|
if(value.$hydrate) {
|
|
@@ -1400,7 +1378,9 @@ var NativeDocument = (function (exports) {
|
|
|
1400
1378
|
* @param {Object} data
|
|
1401
1379
|
*/
|
|
1402
1380
|
function bindStyleAttribute(element, data) {
|
|
1403
|
-
|
|
1381
|
+
const keys = Object.keys(data);
|
|
1382
|
+
for(let i = 0, length = keys.length; i < length; i++) {
|
|
1383
|
+
const styleName = keys[i];
|
|
1404
1384
|
const value = data[styleName];
|
|
1405
1385
|
if(value.__$isObservable) {
|
|
1406
1386
|
element.style[styleName] = value.val();
|
|
@@ -1468,10 +1448,12 @@ var NativeDocument = (function (exports) {
|
|
|
1468
1448
|
function AttributesWrapper(element, attributes) {
|
|
1469
1449
|
|
|
1470
1450
|
Validator.validateAttributes(attributes);
|
|
1451
|
+
const attributesKeys = Object.keys(attributes);
|
|
1471
1452
|
|
|
1472
|
-
for(let
|
|
1473
|
-
const
|
|
1474
|
-
|
|
1453
|
+
for(let i = 0, length = attributesKeys.length; i < length; i++) {
|
|
1454
|
+
const originalAttributeName = attributesKeys[i];
|
|
1455
|
+
const attributeName = originalAttributeName.toLowerCase();
|
|
1456
|
+
let value = attributes[originalAttributeName];
|
|
1475
1457
|
if(value == null) {
|
|
1476
1458
|
continue;
|
|
1477
1459
|
}
|
|
@@ -1544,7 +1526,7 @@ var NativeDocument = (function (exports) {
|
|
|
1544
1526
|
Function.prototype.toNdElement = function () {
|
|
1545
1527
|
const child = this;
|
|
1546
1528
|
{
|
|
1547
|
-
PluginsManager.emit('BeforeProcessComponent', child);
|
|
1529
|
+
PluginsManager$1.emit('BeforeProcessComponent', child);
|
|
1548
1530
|
}
|
|
1549
1531
|
return ElementCreator.getChild(child());
|
|
1550
1532
|
};
|
|
@@ -1650,14 +1632,14 @@ var NativeDocument = (function (exports) {
|
|
|
1650
1632
|
processChildren(children, parent) {
|
|
1651
1633
|
if(children === null) return;
|
|
1652
1634
|
{
|
|
1653
|
-
PluginsManager.emit('BeforeProcessChildren', parent);
|
|
1635
|
+
PluginsManager$1.emit('BeforeProcessChildren', parent);
|
|
1654
1636
|
}
|
|
1655
1637
|
let child = this.getChild(children);
|
|
1656
1638
|
if(child) {
|
|
1657
1639
|
parent.appendChild(child);
|
|
1658
1640
|
}
|
|
1659
1641
|
{
|
|
1660
|
-
PluginsManager.emit('AfterProcessChildren', parent);
|
|
1642
|
+
PluginsManager$1.emit('AfterProcessChildren', parent);
|
|
1661
1643
|
}
|
|
1662
1644
|
},
|
|
1663
1645
|
getChild(child) {
|
|
@@ -2882,7 +2864,7 @@ var NativeDocument = (function (exports) {
|
|
|
2882
2864
|
|
|
2883
2865
|
ObservableItem.call(this, target, configs);
|
|
2884
2866
|
{
|
|
2885
|
-
PluginsManager.emit('CreateObservableArray', this);
|
|
2867
|
+
PluginsManager$1.emit('CreateObservableArray', this);
|
|
2886
2868
|
}
|
|
2887
2869
|
};
|
|
2888
2870
|
|
|
@@ -3283,7 +3265,7 @@ var NativeDocument = (function (exports) {
|
|
|
3283
3265
|
const observable = new ObservableItem(initialValue);
|
|
3284
3266
|
const updatedValue = nextTick(() => observable.set(callback()));
|
|
3285
3267
|
{
|
|
3286
|
-
PluginsManager.emit('CreateObservableComputed', observable, dependencies);
|
|
3268
|
+
PluginsManager$1.emit('CreateObservableComputed', observable, dependencies);
|
|
3287
3269
|
}
|
|
3288
3270
|
|
|
3289
3271
|
if(Validator.isFunction(dependencies)) {
|
|
@@ -3443,7 +3425,7 @@ var NativeDocument = (function (exports) {
|
|
|
3443
3425
|
}
|
|
3444
3426
|
cache.set(keyId, { keyId, isNew: true, child: new WeakRef(child), indexObserver});
|
|
3445
3427
|
} catch (e) {
|
|
3446
|
-
DebugManager.error('ForEach', `Error creating element for key ${keyId}` , e);
|
|
3428
|
+
DebugManager$1.error('ForEach', `Error creating element for key ${keyId}` , e);
|
|
3447
3429
|
throw e;
|
|
3448
3430
|
}
|
|
3449
3431
|
return keyId;
|
|
@@ -3789,7 +3771,7 @@ var NativeDocument = (function (exports) {
|
|
|
3789
3771
|
*/
|
|
3790
3772
|
const ShowIf = function(condition, child, { comment = null, shouldKeepInCache = true} = {}) {
|
|
3791
3773
|
if(!(Validator.isObservable(condition)) && !Validator.isObservableWhenResult(condition)) {
|
|
3792
|
-
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);
|
|
3793
3775
|
}
|
|
3794
3776
|
const element = Anchor('Show if : '+(comment || ''));
|
|
3795
3777
|
|
|
@@ -4576,7 +4558,7 @@ var NativeDocument = (function (exports) {
|
|
|
4576
4558
|
window.history.pushState({ name: route.name(), params, path}, route.name() || path , path);
|
|
4577
4559
|
this.handleRouteChange(route, params, query, path);
|
|
4578
4560
|
} catch (e) {
|
|
4579
|
-
DebugManager.error('HistoryRouter', 'Error in pushState', e);
|
|
4561
|
+
DebugManager$1.error('HistoryRouter', 'Error in pushState', e);
|
|
4580
4562
|
}
|
|
4581
4563
|
};
|
|
4582
4564
|
/**
|
|
@@ -4589,7 +4571,7 @@ var NativeDocument = (function (exports) {
|
|
|
4589
4571
|
window.history.replaceState({ name: route.name(), params, path}, route.name() || path , path);
|
|
4590
4572
|
this.handleRouteChange(route, params, {}, path);
|
|
4591
4573
|
} catch(e) {
|
|
4592
|
-
DebugManager.error('HistoryRouter', 'Error in replaceState', e);
|
|
4574
|
+
DebugManager$1.error('HistoryRouter', 'Error in replaceState', e);
|
|
4593
4575
|
}
|
|
4594
4576
|
};
|
|
4595
4577
|
this.forward = function() {
|
|
@@ -4616,7 +4598,7 @@ var NativeDocument = (function (exports) {
|
|
|
4616
4598
|
}
|
|
4617
4599
|
this.handleRouteChange(route, params, query, path);
|
|
4618
4600
|
} catch(e) {
|
|
4619
|
-
DebugManager.error('HistoryRouter', 'Error in popstate event', e);
|
|
4601
|
+
DebugManager$1.error('HistoryRouter', 'Error in popstate event', e);
|
|
4620
4602
|
}
|
|
4621
4603
|
});
|
|
4622
4604
|
const { route, params, query, path } = this.resolve(defaultPath || (window.location.pathname+window.location.search));
|
|
@@ -4841,7 +4823,7 @@ var NativeDocument = (function (exports) {
|
|
|
4841
4823
|
listener(request);
|
|
4842
4824
|
next && next(request);
|
|
4843
4825
|
} catch (e) {
|
|
4844
|
-
DebugManager.warn('Route Listener', 'Error in listener:', e);
|
|
4826
|
+
DebugManager$1.warn('Route Listener', 'Error in listener:', e);
|
|
4845
4827
|
}
|
|
4846
4828
|
}
|
|
4847
4829
|
};
|
|
@@ -5000,7 +4982,7 @@ var NativeDocument = (function (exports) {
|
|
|
5000
4982
|
*/
|
|
5001
4983
|
Router.create = function(options, callback) {
|
|
5002
4984
|
if(!Validator.isFunction(callback)) {
|
|
5003
|
-
DebugManager.error('Router', 'Callback must be a function', e);
|
|
4985
|
+
DebugManager$1.error('Router', 'Callback must be a function', e);
|
|
5004
4986
|
throw new RouterError('Callback must be a function');
|
|
5005
4987
|
}
|
|
5006
4988
|
const router = new Router(options);
|
|
@@ -5184,7 +5166,7 @@ var NativeDocument = (function (exports) {
|
|
|
5184
5166
|
exports.HtmlElementWrapper = HtmlElementWrapper;
|
|
5185
5167
|
exports.NDElement = NDElement;
|
|
5186
5168
|
exports.Observable = Observable;
|
|
5187
|
-
exports.PluginsManager = PluginsManager;
|
|
5169
|
+
exports.PluginsManager = PluginsManager$1;
|
|
5188
5170
|
exports.SingletonView = SingletonView;
|
|
5189
5171
|
exports.Store = Store;
|
|
5190
5172
|
exports.TemplateCloner = TemplateCloner;
|