native-document 1.0.121 → 1.0.122
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/package.json
CHANGED
|
@@ -28,7 +28,6 @@ const CREATE_AND_CACHE_ACTIONS = new Set(['clear', 'push', 'unshift', 'replace']
|
|
|
28
28
|
export function ForEachArray(data, callback, configs = {}) {
|
|
29
29
|
const element = Anchor('ForEach Array', configs.isParentUniqueChild);
|
|
30
30
|
const blockEnd = element.endElement();
|
|
31
|
-
const blockStart = element.startElement();
|
|
32
31
|
|
|
33
32
|
let cache = new Map();
|
|
34
33
|
let lastNumberOfItems = 0;
|
|
@@ -76,7 +75,7 @@ export function ForEachArray(data, callback, configs = {}) {
|
|
|
76
75
|
};
|
|
77
76
|
|
|
78
77
|
const createAndCache = (item) => {
|
|
79
|
-
const child =
|
|
78
|
+
const child = callback(item, null);
|
|
80
79
|
if(process.env.NODE_ENV === 'development') {
|
|
81
80
|
if(!child) {
|
|
82
81
|
throw new NativeDocumentError("ForEachArray child can't be null or undefined!");
|
|
@@ -88,7 +87,7 @@ export function ForEachArray(data, callback, configs = {}) {
|
|
|
88
87
|
|
|
89
88
|
const createWithIndexAndCache = (item, indexKey) => {
|
|
90
89
|
const indexObserver = Observable(indexKey);
|
|
91
|
-
const child =
|
|
90
|
+
const child = callback(item, indexObserver);
|
|
92
91
|
if(process.env.NODE_ENV === 'development') {
|
|
93
92
|
if(!child) {
|
|
94
93
|
throw new NativeDocumentError("ForEachArray child can't be null or undefined!");
|
|
@@ -9,7 +9,8 @@ import {Observable} from "../data/Observable";
|
|
|
9
9
|
*/
|
|
10
10
|
export const bindClassAttribute = (element, data) => {
|
|
11
11
|
for(const className in data) {
|
|
12
|
-
data[className]
|
|
12
|
+
const value = data[className];
|
|
13
|
+
value.bindClassProperty(element, className, value);
|
|
13
14
|
}
|
|
14
15
|
}
|
|
15
16
|
|
|
@@ -3,20 +3,20 @@ import {ObservableWhen} from "../../data/ObservableWhen";
|
|
|
3
3
|
import TemplateBinding from "../../../core/wrappers/TemplateBinding";
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
ObservableItem.prototype.bindClassProperty =
|
|
7
|
-
element.classes.toggle(className,
|
|
8
|
-
|
|
6
|
+
ObservableItem.prototype.bindClassProperty = (element, className, value) => {
|
|
7
|
+
element.classes.toggle(className, value.val());
|
|
8
|
+
value.subscribe((shouldAdd) => element.classes.toggle(className, shouldAdd));
|
|
9
9
|
};
|
|
10
10
|
|
|
11
|
-
ObservableWhen.prototype.bindClassProperty =
|
|
12
|
-
element.classes.toggle(className,
|
|
13
|
-
|
|
11
|
+
ObservableWhen.prototype.bindClassProperty = (element, className, value) => {
|
|
12
|
+
element.classes.toggle(className, value.isActive());
|
|
13
|
+
value.subscribe((shouldAdd) => element.classes.toggle(className, shouldAdd));
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
-
TemplateBinding.prototype.bindClassProperty =
|
|
17
|
-
|
|
16
|
+
TemplateBinding.prototype.bindClassProperty = (element, className, value) => {
|
|
17
|
+
value.$hydrate(element, className);
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
-
Boolean.prototype.bindClassProperty =
|
|
21
|
-
element.classes.toggle(className,
|
|
20
|
+
Boolean.prototype.bindClassProperty = (element, className, value) => {
|
|
21
|
+
element.classes.toggle(className, value);
|
|
22
22
|
};
|
|
@@ -70,7 +70,8 @@ NodeCloner.prototype.resolve = function() {
|
|
|
70
70
|
const key = keys[0];
|
|
71
71
|
const callback = this.$classes[key];
|
|
72
72
|
steps.push((clonedNode, data) => {
|
|
73
|
-
callback.apply(null, data)
|
|
73
|
+
const value = callback.apply(null, data);
|
|
74
|
+
value.bindClassProperty(clonedNode, key, value);
|
|
74
75
|
});
|
|
75
76
|
} else {
|
|
76
77
|
const properties = this.$classes;
|
|
@@ -78,7 +79,8 @@ NodeCloner.prototype.resolve = function() {
|
|
|
78
79
|
steps.push((clonedNode, data) => {
|
|
79
80
|
for(let i = 0; i < keysLength; i++) {
|
|
80
81
|
const key = keys[i];
|
|
81
|
-
properties[key].apply(null, data)
|
|
82
|
+
const value = properties[key].apply(null, data);
|
|
83
|
+
value.bindClassProperty(clonedNode, key, value);
|
|
82
84
|
}
|
|
83
85
|
});
|
|
84
86
|
}
|