native-document 1.0.23 → 1.0.25
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.dev.js +18 -15
- package/dist/native-document.dev.js.map +1 -1
- package/dist/native-document.min.js +1 -1
- package/package.json +1 -1
- package/src/data/ObservableItem.js +4 -0
- package/src/elements/control/for-each-array.js +19 -20
- package/src/wrappers/AttributesWrapper.js +24 -15
- package/src/wrappers/ElementCreator.js +10 -10
|
@@ -985,20 +985,14 @@ var NativeDocument = (function (exports) {
|
|
|
985
985
|
let value = attributes[attributeName];
|
|
986
986
|
if(Validator.isString(value) && Validator.isFunction(value.resolveObservableTemplate)) {
|
|
987
987
|
value = value.resolveObservableTemplate();
|
|
988
|
-
if(Validator.
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
return value.map(item => Validator.isObservable(item) ? item.val() : item).join(' ') || ' ';
|
|
992
|
-
}, observables);
|
|
988
|
+
if(Validator.isString(value)) {
|
|
989
|
+
element.setAttribute(attributeName, value);
|
|
990
|
+
continue;
|
|
993
991
|
}
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
}
|
|
999
|
-
if(Validator.isObservable(value)) {
|
|
1000
|
-
bindAttributeWithObservable(element, attributeName, value);
|
|
1001
|
-
continue;
|
|
992
|
+
const observables = value.filter(item => Validator.isObservable(item));
|
|
993
|
+
value = Observable.computed(() => {
|
|
994
|
+
return value.map(item => Validator.isObservable(item) ? item.val() : item).join(' ') || ' ';
|
|
995
|
+
}, observables);
|
|
1002
996
|
}
|
|
1003
997
|
if(attributeName === 'class' && Validator.isJson(value)) {
|
|
1004
998
|
bindClassAttribute(element, value);
|
|
@@ -1008,6 +1002,14 @@ var NativeDocument = (function (exports) {
|
|
|
1008
1002
|
bindStyleAttribute(element, value);
|
|
1009
1003
|
continue;
|
|
1010
1004
|
}
|
|
1005
|
+
if(BOOLEAN_ATTRIBUTES.includes(attributeName)) {
|
|
1006
|
+
bindBooleanAttribute(element, attributeName, value);
|
|
1007
|
+
continue;
|
|
1008
|
+
}
|
|
1009
|
+
if(Validator.isObservable(value)) {
|
|
1010
|
+
bindAttributeWithObservable(element, attributeName, value);
|
|
1011
|
+
continue;
|
|
1012
|
+
}
|
|
1011
1013
|
element.setAttribute(attributeName, value);
|
|
1012
1014
|
|
|
1013
1015
|
}
|
|
@@ -1770,6 +1772,7 @@ var NativeDocument = (function (exports) {
|
|
|
1770
1772
|
|
|
1771
1773
|
let cache = new Map();
|
|
1772
1774
|
let lastNumberOfItems = 0;
|
|
1775
|
+
const isIndexRequired = callback.length >= 2;
|
|
1773
1776
|
|
|
1774
1777
|
const keysCache = new WeakMap();
|
|
1775
1778
|
|
|
@@ -1789,7 +1792,7 @@ var NativeDocument = (function (exports) {
|
|
|
1789
1792
|
};
|
|
1790
1793
|
|
|
1791
1794
|
const updateIndexObservers = (items, startFrom = 0) => {
|
|
1792
|
-
if(
|
|
1795
|
+
if(!isIndexRequired) {
|
|
1793
1796
|
return;
|
|
1794
1797
|
}
|
|
1795
1798
|
let index = startFrom;
|
|
@@ -1842,7 +1845,7 @@ var NativeDocument = (function (exports) {
|
|
|
1842
1845
|
}
|
|
1843
1846
|
|
|
1844
1847
|
try {
|
|
1845
|
-
const indexObserver =
|
|
1848
|
+
const indexObserver = isIndexRequired ? Observable(indexKey) : null;
|
|
1846
1849
|
let child = ElementCreator.getChild(callback(item, indexObserver));
|
|
1847
1850
|
cache.set(keyId, {
|
|
1848
1851
|
keyId,
|