native-document 1.0.87 → 1.0.88
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 +38 -50
- package/dist/native-document.dev.js +58 -81
- 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/wrappers/AttributesWrapper.js +21 -41
- package/src/core/wrappers/ElementCreator.js +8 -0
- package/src/core/wrappers/TemplateCloner.js +10 -22
|
@@ -256,16 +256,16 @@ var NativeComponents = (function (exports) {
|
|
|
256
256
|
return this.$build();
|
|
257
257
|
};
|
|
258
258
|
|
|
259
|
-
let DebugManager = {};
|
|
259
|
+
let DebugManager$1 = {};
|
|
260
260
|
{
|
|
261
|
-
DebugManager = {
|
|
261
|
+
DebugManager$1 = {
|
|
262
262
|
log() {},
|
|
263
263
|
warn() {},
|
|
264
264
|
error() {},
|
|
265
265
|
disable() {}
|
|
266
266
|
};
|
|
267
267
|
}
|
|
268
|
-
var DebugManager
|
|
268
|
+
var DebugManager = DebugManager$1;
|
|
269
269
|
|
|
270
270
|
const MemoryManager = (function() {
|
|
271
271
|
|
|
@@ -314,7 +314,7 @@ var NativeComponents = (function (exports) {
|
|
|
314
314
|
}
|
|
315
315
|
}
|
|
316
316
|
if (cleanedCount > 0) {
|
|
317
|
-
DebugManager
|
|
317
|
+
DebugManager.log('Memory Auto Clean', `🧹 Cleaned ${cleanedCount} orphaned observables`);
|
|
318
318
|
}
|
|
319
319
|
}
|
|
320
320
|
};
|
|
@@ -662,7 +662,7 @@ var NativeComponents = (function (exports) {
|
|
|
662
662
|
ObservableItem.prototype.subscribe = function(callback, target = null) {
|
|
663
663
|
this.$listeners = this.$listeners ?? [];
|
|
664
664
|
if (this.$isCleanedUp) {
|
|
665
|
-
DebugManager
|
|
665
|
+
DebugManager.warn('Observable subscription', '⚠️ Attempted to subscribe to a cleaned up observable.');
|
|
666
666
|
return () => {};
|
|
667
667
|
}
|
|
668
668
|
if (typeof callback !== 'function') {
|
|
@@ -1035,17 +1035,17 @@ var NativeComponents = (function (exports) {
|
|
|
1035
1035
|
const method = methods[name];
|
|
1036
1036
|
|
|
1037
1037
|
if (typeof method !== 'function') {
|
|
1038
|
-
DebugManager
|
|
1038
|
+
DebugManager.warn('NDElement.extend', `"${name}" is not a function, skipping`);
|
|
1039
1039
|
continue;
|
|
1040
1040
|
}
|
|
1041
1041
|
|
|
1042
1042
|
if (protectedMethods.has(name)) {
|
|
1043
|
-
DebugManager
|
|
1043
|
+
DebugManager.error('NDElement.extend', `Cannot override protected method "${name}"`);
|
|
1044
1044
|
throw new NativeDocumentError(`Cannot override protected method "${name}"`);
|
|
1045
1045
|
}
|
|
1046
1046
|
|
|
1047
1047
|
if (NDElement.prototype[name]) {
|
|
1048
|
-
DebugManager
|
|
1048
|
+
DebugManager.warn('NDElement.extend', `Overwriting existing prototype method "${name}"`);
|
|
1049
1049
|
}
|
|
1050
1050
|
|
|
1051
1051
|
NDElement.prototype[name] = method;
|
|
@@ -1227,7 +1227,7 @@ var NativeComponents = (function (exports) {
|
|
|
1227
1227
|
anchorFragment.appendChild = function(child, before = null) {
|
|
1228
1228
|
const parent = anchorEnd.parentNode;
|
|
1229
1229
|
if(!parent) {
|
|
1230
|
-
DebugManager
|
|
1230
|
+
DebugManager.error('Anchor', 'Anchor : parent not found', child);
|
|
1231
1231
|
return;
|
|
1232
1232
|
}
|
|
1233
1233
|
before = before ?? anchorEnd;
|
|
@@ -1440,26 +1440,6 @@ var NativeComponents = (function (exports) {
|
|
|
1440
1440
|
element.classes.toggle(className, shouldAdd);
|
|
1441
1441
|
}
|
|
1442
1442
|
|
|
1443
|
-
function toggleElementStyle(element, styleName, newValue) {
|
|
1444
|
-
element.style[styleName] = newValue;
|
|
1445
|
-
}
|
|
1446
|
-
|
|
1447
|
-
function updateInputFromObserver(element, attributeName, newValue) {
|
|
1448
|
-
if(Validator.isBoolean(newValue)) {
|
|
1449
|
-
element[attributeName] = newValue;
|
|
1450
|
-
return;
|
|
1451
|
-
}
|
|
1452
|
-
element[attributeName] = newValue === element.value;
|
|
1453
|
-
}
|
|
1454
|
-
|
|
1455
|
-
function updateObserverFromInput(element, attributeName, defaultValue, value) {
|
|
1456
|
-
if(Validator.isBoolean(defaultValue)) {
|
|
1457
|
-
value.set(element[attributeName]);
|
|
1458
|
-
return;
|
|
1459
|
-
}
|
|
1460
|
-
value.set(element.value);
|
|
1461
|
-
}
|
|
1462
|
-
|
|
1463
1443
|
/**
|
|
1464
1444
|
*
|
|
1465
1445
|
* @param {HTMLElement} element
|
|
@@ -1468,12 +1448,12 @@ var NativeComponents = (function (exports) {
|
|
|
1468
1448
|
function bindClassAttribute(element, data) {
|
|
1469
1449
|
for(let className in data) {
|
|
1470
1450
|
const value = data[className];
|
|
1471
|
-
if(
|
|
1451
|
+
if(value.__$isObservable) {
|
|
1472
1452
|
element.classes.toggle(className, value.val());
|
|
1473
1453
|
value.subscribe(toggleElementClass.bind(null, element, className));
|
|
1474
1454
|
continue;
|
|
1475
1455
|
}
|
|
1476
|
-
if(
|
|
1456
|
+
if(value.__$isObservableWhen) {
|
|
1477
1457
|
element.classes.toggle(className, value.isMath());
|
|
1478
1458
|
value.subscribe(toggleElementClass.bind(null, element, className));
|
|
1479
1459
|
continue;
|
|
@@ -1495,9 +1475,9 @@ var NativeComponents = (function (exports) {
|
|
|
1495
1475
|
function bindStyleAttribute(element, data) {
|
|
1496
1476
|
for(let styleName in data) {
|
|
1497
1477
|
const value = data[styleName];
|
|
1498
|
-
if(
|
|
1478
|
+
if(value.__$isObservable) {
|
|
1499
1479
|
element.style[styleName] = value.val();
|
|
1500
|
-
value.subscribe(
|
|
1480
|
+
value.subscribe((newValue) => element.style[styleName] = newValue);
|
|
1501
1481
|
continue;
|
|
1502
1482
|
}
|
|
1503
1483
|
element.style[styleName] = value;
|
|
@@ -1511,18 +1491,26 @@ var NativeComponents = (function (exports) {
|
|
|
1511
1491
|
* @param {boolean|number|Observable} value
|
|
1512
1492
|
*/
|
|
1513
1493
|
function bindBooleanAttribute(element, attributeName, value) {
|
|
1514
|
-
const
|
|
1494
|
+
const isObservable = value.__$isObservable;
|
|
1495
|
+
const defaultValue = isObservable? value.val() : value;
|
|
1515
1496
|
if(Validator.isBoolean(defaultValue)) {
|
|
1516
1497
|
element[attributeName] = defaultValue;
|
|
1517
1498
|
}
|
|
1518
1499
|
else {
|
|
1519
1500
|
element[attributeName] = defaultValue === element.value;
|
|
1520
1501
|
}
|
|
1521
|
-
if(
|
|
1522
|
-
if(
|
|
1523
|
-
|
|
1502
|
+
if(isObservable) {
|
|
1503
|
+
if(attributeName === 'checked') {
|
|
1504
|
+
if(typeof defaultValue === 'boolean') {
|
|
1505
|
+
element.addEventListener('input', () => value.set(element[attributeName]));
|
|
1506
|
+
}
|
|
1507
|
+
else {
|
|
1508
|
+
element.addEventListener('input', () => value.set(element.value));
|
|
1509
|
+
}
|
|
1510
|
+
value.subscribe((newValue) => element[attributeName] = newValue);
|
|
1511
|
+
return;
|
|
1524
1512
|
}
|
|
1525
|
-
value.subscribe(
|
|
1513
|
+
value.subscribe((newValue) => element[attributeName] = (newValue === element.value));
|
|
1526
1514
|
}
|
|
1527
1515
|
}
|
|
1528
1516
|
|
|
@@ -1534,19 +1522,15 @@ var NativeComponents = (function (exports) {
|
|
|
1534
1522
|
* @param {Observable} value
|
|
1535
1523
|
*/
|
|
1536
1524
|
function bindAttributeWithObservable(element, attributeName, value) {
|
|
1537
|
-
const applyValue = (newValue) =>
|
|
1538
|
-
if(attributeName === 'value') {
|
|
1539
|
-
element.value = newValue;
|
|
1540
|
-
return;
|
|
1541
|
-
}
|
|
1542
|
-
element.setAttribute(attributeName, newValue);
|
|
1543
|
-
};
|
|
1544
|
-
applyValue(value.val());
|
|
1525
|
+
const applyValue = attributeName === 'value' ? (newValue) => element.value = newValue : (newValue) => element.setAttribute(attributeName, newValue);
|
|
1545
1526
|
value.subscribe(applyValue);
|
|
1546
1527
|
|
|
1547
1528
|
if(attributeName === 'value') {
|
|
1529
|
+
element.value = value.val();
|
|
1548
1530
|
element.addEventListener('input', () => value.set(element.value));
|
|
1531
|
+
return;
|
|
1549
1532
|
}
|
|
1533
|
+
element.setAttribute(attributeName, value.val());
|
|
1550
1534
|
}
|
|
1551
1535
|
|
|
1552
1536
|
/**
|
|
@@ -1556,10 +1540,6 @@ var NativeComponents = (function (exports) {
|
|
|
1556
1540
|
*/
|
|
1557
1541
|
function AttributesWrapper(element, attributes) {
|
|
1558
1542
|
|
|
1559
|
-
if(!Validator.isObject(attributes)) {
|
|
1560
|
-
throw new NativeDocumentError('Attributes must be an object');
|
|
1561
|
-
}
|
|
1562
|
-
|
|
1563
1543
|
for(let key in attributes) {
|
|
1564
1544
|
const attributeName = key.toLowerCase();
|
|
1565
1545
|
let value = attributes[attributeName];
|
|
@@ -1714,6 +1694,14 @@ var NativeComponents = (function (exports) {
|
|
|
1714
1694
|
}
|
|
1715
1695
|
return Anchor('Fragment');
|
|
1716
1696
|
},
|
|
1697
|
+
bindTextNode(textNode, value) {
|
|
1698
|
+
if(value?.__$isObservable) {
|
|
1699
|
+
value.subscribe(newValue => textNode.nodeValue = newValue);
|
|
1700
|
+
textNode.nodeValue = value.val();
|
|
1701
|
+
return;
|
|
1702
|
+
}
|
|
1703
|
+
textNode.nodeValue = value;
|
|
1704
|
+
},
|
|
1717
1705
|
/**
|
|
1718
1706
|
*
|
|
1719
1707
|
* @param {*} children
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
var NativeDocument = (function (exports) {
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
let DebugManager = {};
|
|
4
|
+
let DebugManager$1 = {};
|
|
5
5
|
|
|
6
6
|
{
|
|
7
|
-
DebugManager = {
|
|
7
|
+
DebugManager$1 = {
|
|
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
|
|
38
|
+
var DebugManager = DebugManager$1;
|
|
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
|
|
87
|
+
DebugManager.log('Memory Auto Clean', `🧹 Cleaned ${cleanedCount} orphaned observables`);
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
};
|
|
@@ -210,7 +210,7 @@ var NativeDocument = (function (exports) {
|
|
|
210
210
|
try{
|
|
211
211
|
callback.call(plugin, ...data);
|
|
212
212
|
} catch (error) {
|
|
213
|
-
DebugManager
|
|
213
|
+
DebugManager.error('Plugin Manager', `Error in plugin ${plugin.$name} for event ${eventName}`, error);
|
|
214
214
|
}
|
|
215
215
|
}
|
|
216
216
|
}
|
|
@@ -525,7 +525,7 @@ var NativeDocument = (function (exports) {
|
|
|
525
525
|
ObservableItem.prototype.subscribe = function(callback, target = null) {
|
|
526
526
|
this.$listeners = this.$listeners ?? [];
|
|
527
527
|
if (this.$isCleanedUp) {
|
|
528
|
-
DebugManager
|
|
528
|
+
DebugManager.warn('Observable subscription', '⚠️ Attempted to subscribe to a cleaned up observable.');
|
|
529
529
|
return () => {};
|
|
530
530
|
}
|
|
531
531
|
if (typeof callback !== 'function') {
|
|
@@ -884,7 +884,7 @@ var NativeDocument = (function (exports) {
|
|
|
884
884
|
}
|
|
885
885
|
{
|
|
886
886
|
if (this[name] && !this.$localExtensions.has(name)) {
|
|
887
|
-
DebugManager
|
|
887
|
+
DebugManager.warn('NDElement.extend', `Method "${name}" already exists and will be overwritten`);
|
|
888
888
|
}
|
|
889
889
|
this.$localExtensions.set(name, method);
|
|
890
890
|
}
|
|
@@ -918,17 +918,17 @@ var NativeDocument = (function (exports) {
|
|
|
918
918
|
const method = methods[name];
|
|
919
919
|
|
|
920
920
|
if (typeof method !== 'function') {
|
|
921
|
-
DebugManager
|
|
921
|
+
DebugManager.warn('NDElement.extend', `"${name}" is not a function, skipping`);
|
|
922
922
|
continue;
|
|
923
923
|
}
|
|
924
924
|
|
|
925
925
|
if (protectedMethods.has(name)) {
|
|
926
|
-
DebugManager
|
|
926
|
+
DebugManager.error('NDElement.extend', `Cannot override protected method "${name}"`);
|
|
927
927
|
throw new NativeDocumentError(`Cannot override protected method "${name}"`);
|
|
928
928
|
}
|
|
929
929
|
|
|
930
930
|
if (NDElement.prototype[name]) {
|
|
931
|
-
DebugManager
|
|
931
|
+
DebugManager.warn('NDElement.extend', `Overwriting existing prototype method "${name}"`);
|
|
932
932
|
}
|
|
933
933
|
|
|
934
934
|
NDElement.prototype[name] = method;
|
|
@@ -1087,7 +1087,7 @@ var NativeDocument = (function (exports) {
|
|
|
1087
1087
|
const foundReserved = Object.keys(attributes).filter(key => reserved.includes(key));
|
|
1088
1088
|
|
|
1089
1089
|
if (foundReserved.length > 0) {
|
|
1090
|
-
DebugManager
|
|
1090
|
+
DebugManager.warn('Validator', `Reserved attributes found: ${foundReserved.join(', ')}`);
|
|
1091
1091
|
}
|
|
1092
1092
|
|
|
1093
1093
|
return attributes;
|
|
@@ -1135,7 +1135,7 @@ var NativeDocument = (function (exports) {
|
|
|
1135
1135
|
anchorFragment.appendChild = function(child, before = null) {
|
|
1136
1136
|
const parent = anchorEnd.parentNode;
|
|
1137
1137
|
if(!parent) {
|
|
1138
|
-
DebugManager
|
|
1138
|
+
DebugManager.error('Anchor', 'Anchor : parent not found', child);
|
|
1139
1139
|
return;
|
|
1140
1140
|
}
|
|
1141
1141
|
before = before ?? anchorEnd;
|
|
@@ -1367,26 +1367,6 @@ var NativeDocument = (function (exports) {
|
|
|
1367
1367
|
element.classes.toggle(className, shouldAdd);
|
|
1368
1368
|
}
|
|
1369
1369
|
|
|
1370
|
-
function toggleElementStyle(element, styleName, newValue) {
|
|
1371
|
-
element.style[styleName] = newValue;
|
|
1372
|
-
}
|
|
1373
|
-
|
|
1374
|
-
function updateInputFromObserver(element, attributeName, newValue) {
|
|
1375
|
-
if(Validator.isBoolean(newValue)) {
|
|
1376
|
-
element[attributeName] = newValue;
|
|
1377
|
-
return;
|
|
1378
|
-
}
|
|
1379
|
-
element[attributeName] = newValue === element.value;
|
|
1380
|
-
}
|
|
1381
|
-
|
|
1382
|
-
function updateObserverFromInput(element, attributeName, defaultValue, value) {
|
|
1383
|
-
if(Validator.isBoolean(defaultValue)) {
|
|
1384
|
-
value.set(element[attributeName]);
|
|
1385
|
-
return;
|
|
1386
|
-
}
|
|
1387
|
-
value.set(element.value);
|
|
1388
|
-
}
|
|
1389
|
-
|
|
1390
1370
|
/**
|
|
1391
1371
|
*
|
|
1392
1372
|
* @param {HTMLElement} element
|
|
@@ -1395,12 +1375,12 @@ var NativeDocument = (function (exports) {
|
|
|
1395
1375
|
function bindClassAttribute(element, data) {
|
|
1396
1376
|
for(let className in data) {
|
|
1397
1377
|
const value = data[className];
|
|
1398
|
-
if(
|
|
1378
|
+
if(value.__$isObservable) {
|
|
1399
1379
|
element.classes.toggle(className, value.val());
|
|
1400
1380
|
value.subscribe(toggleElementClass.bind(null, element, className));
|
|
1401
1381
|
continue;
|
|
1402
1382
|
}
|
|
1403
|
-
if(
|
|
1383
|
+
if(value.__$isObservableWhen) {
|
|
1404
1384
|
element.classes.toggle(className, value.isMath());
|
|
1405
1385
|
value.subscribe(toggleElementClass.bind(null, element, className));
|
|
1406
1386
|
continue;
|
|
@@ -1422,9 +1402,9 @@ var NativeDocument = (function (exports) {
|
|
|
1422
1402
|
function bindStyleAttribute(element, data) {
|
|
1423
1403
|
for(let styleName in data) {
|
|
1424
1404
|
const value = data[styleName];
|
|
1425
|
-
if(
|
|
1405
|
+
if(value.__$isObservable) {
|
|
1426
1406
|
element.style[styleName] = value.val();
|
|
1427
|
-
value.subscribe(
|
|
1407
|
+
value.subscribe((newValue) => element.style[styleName] = newValue);
|
|
1428
1408
|
continue;
|
|
1429
1409
|
}
|
|
1430
1410
|
element.style[styleName] = value;
|
|
@@ -1438,18 +1418,26 @@ var NativeDocument = (function (exports) {
|
|
|
1438
1418
|
* @param {boolean|number|Observable} value
|
|
1439
1419
|
*/
|
|
1440
1420
|
function bindBooleanAttribute(element, attributeName, value) {
|
|
1441
|
-
const
|
|
1421
|
+
const isObservable = value.__$isObservable;
|
|
1422
|
+
const defaultValue = isObservable? value.val() : value;
|
|
1442
1423
|
if(Validator.isBoolean(defaultValue)) {
|
|
1443
1424
|
element[attributeName] = defaultValue;
|
|
1444
1425
|
}
|
|
1445
1426
|
else {
|
|
1446
1427
|
element[attributeName] = defaultValue === element.value;
|
|
1447
1428
|
}
|
|
1448
|
-
if(
|
|
1449
|
-
if(
|
|
1450
|
-
|
|
1429
|
+
if(isObservable) {
|
|
1430
|
+
if(attributeName === 'checked') {
|
|
1431
|
+
if(typeof defaultValue === 'boolean') {
|
|
1432
|
+
element.addEventListener('input', () => value.set(element[attributeName]));
|
|
1433
|
+
}
|
|
1434
|
+
else {
|
|
1435
|
+
element.addEventListener('input', () => value.set(element.value));
|
|
1436
|
+
}
|
|
1437
|
+
value.subscribe((newValue) => element[attributeName] = newValue);
|
|
1438
|
+
return;
|
|
1451
1439
|
}
|
|
1452
|
-
value.subscribe(
|
|
1440
|
+
value.subscribe((newValue) => element[attributeName] = (newValue === element.value));
|
|
1453
1441
|
}
|
|
1454
1442
|
}
|
|
1455
1443
|
|
|
@@ -1461,19 +1449,15 @@ var NativeDocument = (function (exports) {
|
|
|
1461
1449
|
* @param {Observable} value
|
|
1462
1450
|
*/
|
|
1463
1451
|
function bindAttributeWithObservable(element, attributeName, value) {
|
|
1464
|
-
const applyValue = (newValue) =>
|
|
1465
|
-
if(attributeName === 'value') {
|
|
1466
|
-
element.value = newValue;
|
|
1467
|
-
return;
|
|
1468
|
-
}
|
|
1469
|
-
element.setAttribute(attributeName, newValue);
|
|
1470
|
-
};
|
|
1471
|
-
applyValue(value.val());
|
|
1452
|
+
const applyValue = attributeName === 'value' ? (newValue) => element.value = newValue : (newValue) => element.setAttribute(attributeName, newValue);
|
|
1472
1453
|
value.subscribe(applyValue);
|
|
1473
1454
|
|
|
1474
1455
|
if(attributeName === 'value') {
|
|
1456
|
+
element.value = value.val();
|
|
1475
1457
|
element.addEventListener('input', () => value.set(element.value));
|
|
1458
|
+
return;
|
|
1476
1459
|
}
|
|
1460
|
+
element.setAttribute(attributeName, value.val());
|
|
1477
1461
|
}
|
|
1478
1462
|
|
|
1479
1463
|
/**
|
|
@@ -1485,10 +1469,6 @@ var NativeDocument = (function (exports) {
|
|
|
1485
1469
|
|
|
1486
1470
|
Validator.validateAttributes(attributes);
|
|
1487
1471
|
|
|
1488
|
-
if(!Validator.isObject(attributes)) {
|
|
1489
|
-
throw new NativeDocumentError('Attributes must be an object');
|
|
1490
|
-
}
|
|
1491
|
-
|
|
1492
1472
|
for(let key in attributes) {
|
|
1493
1473
|
const attributeName = key.toLowerCase();
|
|
1494
1474
|
let value = attributes[attributeName];
|
|
@@ -1654,6 +1634,14 @@ var NativeDocument = (function (exports) {
|
|
|
1654
1634
|
}
|
|
1655
1635
|
return Anchor('Fragment');
|
|
1656
1636
|
},
|
|
1637
|
+
bindTextNode(textNode, value) {
|
|
1638
|
+
if(value?.__$isObservable) {
|
|
1639
|
+
value.subscribe(newValue => textNode.nodeValue = newValue);
|
|
1640
|
+
textNode.nodeValue = value.val();
|
|
1641
|
+
return;
|
|
1642
|
+
}
|
|
1643
|
+
textNode.nodeValue = value;
|
|
1644
|
+
},
|
|
1657
1645
|
/**
|
|
1658
1646
|
*
|
|
1659
1647
|
* @param {*} children
|
|
@@ -2189,9 +2177,8 @@ var NativeDocument = (function (exports) {
|
|
|
2189
2177
|
|
|
2190
2178
|
|
|
2191
2179
|
const applyBindingTreePath = (root, target, data, path) => {
|
|
2192
|
-
let newTarget = null;
|
|
2193
2180
|
if(path.fn) {
|
|
2194
|
-
|
|
2181
|
+
path.fn(data, target, root);
|
|
2195
2182
|
}
|
|
2196
2183
|
if(path.children) {
|
|
2197
2184
|
for(let i = 0, length = path.children.length; i < length; i++) {
|
|
@@ -2200,7 +2187,6 @@ var NativeDocument = (function (exports) {
|
|
|
2200
2187
|
applyBindingTreePath(root, pathTargetNode, data, currentPath);
|
|
2201
2188
|
}
|
|
2202
2189
|
}
|
|
2203
|
-
return newTarget;
|
|
2204
2190
|
};
|
|
2205
2191
|
|
|
2206
2192
|
function TemplateCloner($fn) {
|
|
@@ -2216,15 +2202,10 @@ var NativeDocument = (function (exports) {
|
|
|
2216
2202
|
const bindDingData = cloneBindingsDataCache.get(node);
|
|
2217
2203
|
if(node.nodeType === 3) {
|
|
2218
2204
|
if(bindDingData && bindDingData.value) {
|
|
2219
|
-
currentPath.fn =
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
}
|
|
2224
|
-
targetNode.replaceWith(newNode);
|
|
2225
|
-
return null;
|
|
2226
|
-
};
|
|
2227
|
-
return bindDingData.value(data);
|
|
2205
|
+
currentPath.fn = bindDingData.value;
|
|
2206
|
+
const textNode = node.cloneNode();
|
|
2207
|
+
bindDingData.value(data, textNode);
|
|
2208
|
+
return textNode;
|
|
2228
2209
|
}
|
|
2229
2210
|
return node.cloneNode(true);
|
|
2230
2211
|
}
|
|
@@ -2261,11 +2242,7 @@ var NativeDocument = (function (exports) {
|
|
|
2261
2242
|
const cloneWithBindingPaths = (data) => {
|
|
2262
2243
|
let root = $node.cloneNode(true);
|
|
2263
2244
|
|
|
2264
|
-
|
|
2265
|
-
if(newRoot) {
|
|
2266
|
-
root = newRoot;
|
|
2267
|
-
}
|
|
2268
|
-
|
|
2245
|
+
applyBindingTreePath(root, root, data, $bindingTreePath);
|
|
2269
2246
|
return root;
|
|
2270
2247
|
};
|
|
2271
2248
|
|
|
@@ -2300,13 +2277,13 @@ var NativeDocument = (function (exports) {
|
|
|
2300
2277
|
};
|
|
2301
2278
|
this.value = (callbackOrProperty) => {
|
|
2302
2279
|
if(typeof callbackOrProperty !== 'function') {
|
|
2303
|
-
return createBinding(function(data) {
|
|
2280
|
+
return createBinding(function(data, textNode) {
|
|
2304
2281
|
const firstArgument = data[0];
|
|
2305
|
-
|
|
2282
|
+
ElementCreator.bindTextNode(textNode, firstArgument[callbackOrProperty]);
|
|
2306
2283
|
}, 'value');
|
|
2307
2284
|
}
|
|
2308
|
-
return createBinding(function(data) {
|
|
2309
|
-
|
|
2285
|
+
return createBinding(function(data, textNode) {
|
|
2286
|
+
ElementCreator.bindTextNode(textNode, callbackOrProperty(...data));
|
|
2310
2287
|
}, 'value');
|
|
2311
2288
|
};
|
|
2312
2289
|
this.attr = (fn) => {
|
|
@@ -3466,7 +3443,7 @@ var NativeDocument = (function (exports) {
|
|
|
3466
3443
|
}
|
|
3467
3444
|
cache.set(keyId, { keyId, isNew: true, child: new WeakRef(child), indexObserver});
|
|
3468
3445
|
} catch (e) {
|
|
3469
|
-
DebugManager
|
|
3446
|
+
DebugManager.error('ForEach', `Error creating element for key ${keyId}` , e);
|
|
3470
3447
|
throw e;
|
|
3471
3448
|
}
|
|
3472
3449
|
return keyId;
|
|
@@ -3812,7 +3789,7 @@ var NativeDocument = (function (exports) {
|
|
|
3812
3789
|
*/
|
|
3813
3790
|
const ShowIf = function(condition, child, { comment = null, shouldKeepInCache = true} = {}) {
|
|
3814
3791
|
if(!(Validator.isObservable(condition)) && !Validator.isObservableWhenResult(condition)) {
|
|
3815
|
-
return DebugManager
|
|
3792
|
+
return DebugManager.warn('ShowIf', "ShowIf : condition must be an Observable / "+comment, condition);
|
|
3816
3793
|
}
|
|
3817
3794
|
const element = Anchor('Show if : '+(comment || ''));
|
|
3818
3795
|
|
|
@@ -4599,7 +4576,7 @@ var NativeDocument = (function (exports) {
|
|
|
4599
4576
|
window.history.pushState({ name: route.name(), params, path}, route.name() || path , path);
|
|
4600
4577
|
this.handleRouteChange(route, params, query, path);
|
|
4601
4578
|
} catch (e) {
|
|
4602
|
-
DebugManager
|
|
4579
|
+
DebugManager.error('HistoryRouter', 'Error in pushState', e);
|
|
4603
4580
|
}
|
|
4604
4581
|
};
|
|
4605
4582
|
/**
|
|
@@ -4612,7 +4589,7 @@ var NativeDocument = (function (exports) {
|
|
|
4612
4589
|
window.history.replaceState({ name: route.name(), params, path}, route.name() || path , path);
|
|
4613
4590
|
this.handleRouteChange(route, params, {}, path);
|
|
4614
4591
|
} catch(e) {
|
|
4615
|
-
DebugManager
|
|
4592
|
+
DebugManager.error('HistoryRouter', 'Error in replaceState', e);
|
|
4616
4593
|
}
|
|
4617
4594
|
};
|
|
4618
4595
|
this.forward = function() {
|
|
@@ -4639,7 +4616,7 @@ var NativeDocument = (function (exports) {
|
|
|
4639
4616
|
}
|
|
4640
4617
|
this.handleRouteChange(route, params, query, path);
|
|
4641
4618
|
} catch(e) {
|
|
4642
|
-
DebugManager
|
|
4619
|
+
DebugManager.error('HistoryRouter', 'Error in popstate event', e);
|
|
4643
4620
|
}
|
|
4644
4621
|
});
|
|
4645
4622
|
const { route, params, query, path } = this.resolve(defaultPath || (window.location.pathname+window.location.search));
|
|
@@ -4864,7 +4841,7 @@ var NativeDocument = (function (exports) {
|
|
|
4864
4841
|
listener(request);
|
|
4865
4842
|
next && next(request);
|
|
4866
4843
|
} catch (e) {
|
|
4867
|
-
DebugManager
|
|
4844
|
+
DebugManager.warn('Route Listener', 'Error in listener:', e);
|
|
4868
4845
|
}
|
|
4869
4846
|
}
|
|
4870
4847
|
};
|
|
@@ -5023,7 +5000,7 @@ var NativeDocument = (function (exports) {
|
|
|
5023
5000
|
*/
|
|
5024
5001
|
Router.create = function(options, callback) {
|
|
5025
5002
|
if(!Validator.isFunction(callback)) {
|
|
5026
|
-
DebugManager
|
|
5003
|
+
DebugManager.error('Router', 'Callback must be a function', e);
|
|
5027
5004
|
throw new RouterError('Callback must be a function');
|
|
5028
5005
|
}
|
|
5029
5006
|
const router = new Router(options);
|