native-document 1.0.122 → 1.0.124
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 +41 -53
- package/dist/native-document.dev.js +89 -106
- package/dist/native-document.dev.js.map +1 -1
- package/dist/native-document.min.js +1 -1
- package/package.json +1 -1
- package/src/core/data/ObservableChecker.js +1 -0
- package/src/core/data/ObservableItem.js +1 -0
- package/src/core/data/ObservableWhen.js +1 -0
- package/src/core/wrappers/AttributesWrapper.js +34 -32
- package/src/core/wrappers/prototypes/bind-class-extensions.js +0 -22
- package/src/core/wrappers/template-cloner/NodeCloner.js +4 -9
|
@@ -386,6 +386,7 @@ var NativeComponents = (function (exports) {
|
|
|
386
386
|
this.unSubscriptions = [];
|
|
387
387
|
}
|
|
388
388
|
|
|
389
|
+
ObservableChecker.prototype.__$Observable = true;
|
|
389
390
|
ObservableChecker.prototype.__$isObservableChecker = true;
|
|
390
391
|
|
|
391
392
|
/**
|
|
@@ -1099,6 +1100,7 @@ var NativeComponents = (function (exports) {
|
|
|
1099
1100
|
this.$observer = observer;
|
|
1100
1101
|
};
|
|
1101
1102
|
|
|
1103
|
+
ObservableWhen.prototype.__$Observable = true;
|
|
1102
1104
|
ObservableWhen.prototype.__$isObservableWhen = true;
|
|
1103
1105
|
|
|
1104
1106
|
/**
|
|
@@ -1404,6 +1406,7 @@ var NativeComponents = (function (exports) {
|
|
|
1404
1406
|
configurable: true,
|
|
1405
1407
|
});
|
|
1406
1408
|
|
|
1409
|
+
ObservableItem.prototype.__$Observable = true;
|
|
1407
1410
|
ObservableItem.prototype.__$isObservable = true;
|
|
1408
1411
|
const noneTrigger = function() {};
|
|
1409
1412
|
|
|
@@ -1969,7 +1972,17 @@ var NativeComponents = (function (exports) {
|
|
|
1969
1972
|
*/
|
|
1970
1973
|
const bindClassAttribute = (element, data) => {
|
|
1971
1974
|
for(const className in data) {
|
|
1972
|
-
data[className]
|
|
1975
|
+
const value = data[className];
|
|
1976
|
+
if(value.__$Observable) {
|
|
1977
|
+
element.classes.toggle(className, value.val());
|
|
1978
|
+
value.subscribe((shouldAdd) => element.classes.toggle(className, shouldAdd));
|
|
1979
|
+
continue;
|
|
1980
|
+
}
|
|
1981
|
+
if(value.$hydrate) {
|
|
1982
|
+
value.$hydrate(element, className);
|
|
1983
|
+
continue;
|
|
1984
|
+
}
|
|
1985
|
+
element.classes.toggle(className, value);
|
|
1973
1986
|
}
|
|
1974
1987
|
};
|
|
1975
1988
|
|
|
@@ -2039,35 +2052,6 @@ var NativeComponents = (function (exports) {
|
|
|
2039
2052
|
element.setAttribute(attributeName, value.val());
|
|
2040
2053
|
};
|
|
2041
2054
|
|
|
2042
|
-
|
|
2043
|
-
const AttributeHandlers = {
|
|
2044
|
-
string: (element, attributeName, value) => element.setAttribute(attributeName, value),
|
|
2045
|
-
number: (element, attributeName, value) => element.setAttribute(attributeName, value),
|
|
2046
|
-
boolean: (element, attributeName, value) => bindBooleanAttribute(element, attributeName, value),
|
|
2047
|
-
object: (element, attributeName, value) => {
|
|
2048
|
-
if(value == null) {
|
|
2049
|
-
return;
|
|
2050
|
-
}
|
|
2051
|
-
|
|
2052
|
-
if(value.handleNdAttribute) {
|
|
2053
|
-
value.handleNdAttribute(element, attributeName);
|
|
2054
|
-
return;
|
|
2055
|
-
}
|
|
2056
|
-
|
|
2057
|
-
if(attributeName === 'class') {
|
|
2058
|
-
bindClassAttribute(element, value);
|
|
2059
|
-
return;
|
|
2060
|
-
}
|
|
2061
|
-
if(attributeName === 'style') {
|
|
2062
|
-
bindStyleAttribute(element, value);
|
|
2063
|
-
return;
|
|
2064
|
-
}
|
|
2065
|
-
if(BOOLEAN_ATTRIBUTES.has(attributeName)) {
|
|
2066
|
-
bindBooleanAttribute(element, attributeName, value);
|
|
2067
|
-
}
|
|
2068
|
-
}
|
|
2069
|
-
};
|
|
2070
|
-
|
|
2071
2055
|
/**
|
|
2072
2056
|
*
|
|
2073
2057
|
* @param {HTMLElement} element
|
|
@@ -2078,8 +2062,29 @@ var NativeComponents = (function (exports) {
|
|
|
2078
2062
|
for(const originalAttributeName in attributes) {
|
|
2079
2063
|
const attributeName = originalAttributeName.toLowerCase();
|
|
2080
2064
|
let value = attributes[originalAttributeName];
|
|
2081
|
-
|
|
2082
|
-
|
|
2065
|
+
if(value == null) {
|
|
2066
|
+
continue;
|
|
2067
|
+
}
|
|
2068
|
+
if(value.handleNdAttribute) {
|
|
2069
|
+
value.handleNdAttribute(element, attributeName, value);
|
|
2070
|
+
continue;
|
|
2071
|
+
}
|
|
2072
|
+
if(typeof value === 'object') {
|
|
2073
|
+
if(attributeName === 'class') {
|
|
2074
|
+
bindClassAttribute(element, value);
|
|
2075
|
+
continue;
|
|
2076
|
+
}
|
|
2077
|
+
if(attributeName === 'style') {
|
|
2078
|
+
bindStyleAttribute(element, value);
|
|
2079
|
+
continue;
|
|
2080
|
+
}
|
|
2081
|
+
}
|
|
2082
|
+
if(BOOLEAN_ATTRIBUTES.has(attributeName)) {
|
|
2083
|
+
bindBooleanAttribute(element, attributeName, value);
|
|
2084
|
+
continue;
|
|
2085
|
+
}
|
|
2086
|
+
|
|
2087
|
+
element.setAttribute(attributeName, value);
|
|
2083
2088
|
}
|
|
2084
2089
|
return element;
|
|
2085
2090
|
};
|
|
@@ -2228,20 +2233,6 @@ var NativeComponents = (function (exports) {
|
|
|
2228
2233
|
bindAttributeWithObservable(element, attributeName, this);
|
|
2229
2234
|
};
|
|
2230
2235
|
|
|
2231
|
-
ObservableItem.prototype.bindClassProperty = function(element, className) {
|
|
2232
|
-
element.classes.toggle(className, this.val());
|
|
2233
|
-
this.subscribe((shouldAdd) => element.classes.toggle(className, shouldAdd));
|
|
2234
|
-
};
|
|
2235
|
-
|
|
2236
|
-
ObservableWhen.prototype.bindClassProperty = function(element, className) {
|
|
2237
|
-
element.classes.toggle(className, this.isActive());
|
|
2238
|
-
this.subscribe((shouldAdd) => element.classes.toggle(className, shouldAdd));
|
|
2239
|
-
};
|
|
2240
|
-
|
|
2241
|
-
Boolean.prototype.bindClassProperty = function(element, className) {
|
|
2242
|
-
element.classes.toggle(className, this);
|
|
2243
|
-
};
|
|
2244
|
-
|
|
2245
2236
|
let $textNodeCache = null;
|
|
2246
2237
|
|
|
2247
2238
|
const ElementCreator = {
|
|
@@ -3073,22 +3064,19 @@ var NativeComponents = (function (exports) {
|
|
|
3073
3064
|
}
|
|
3074
3065
|
}
|
|
3075
3066
|
if(this.$classes) {
|
|
3067
|
+
const cache = {};
|
|
3076
3068
|
const keys = Object.keys(this.$classes);
|
|
3077
3069
|
|
|
3078
3070
|
if(keys.length === 1) {
|
|
3079
3071
|
const key = keys[0];
|
|
3080
3072
|
const callback = this.$classes[key];
|
|
3081
3073
|
steps.push((clonedNode, data) => {
|
|
3082
|
-
callback.apply(null, data)
|
|
3074
|
+
cache[key] = callback.apply(null, data);
|
|
3075
|
+
ElementCreator.processClassAttribute(clonedNode, cache);
|
|
3083
3076
|
});
|
|
3084
3077
|
} else {
|
|
3085
|
-
const properties = this.$classes;
|
|
3086
|
-
const keysLength = keys.length;
|
|
3087
3078
|
steps.push((clonedNode, data) => {
|
|
3088
|
-
|
|
3089
|
-
const key = keys[i];
|
|
3090
|
-
properties[key].apply(null, data).bindClassProperty(clonedNode, key);
|
|
3091
|
-
}
|
|
3079
|
+
ElementCreator.processClassAttribute(clonedNode, buildProperties(cache, this.$classes, data));
|
|
3092
3080
|
});
|
|
3093
3081
|
}
|
|
3094
3082
|
}
|