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
|
@@ -2,12 +2,6 @@ import Validator from "../utils/validator";
|
|
|
2
2
|
import NativeDocumentError from "../errors/NativeDocumentError";
|
|
3
3
|
import {BOOLEAN_ATTRIBUTES} from "./constants.js";
|
|
4
4
|
import {Observable} from "../data/Observable";
|
|
5
|
-
import './prototypes/bind-class-extensions';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export function toggleElementClass(element, className, shouldAdd) {
|
|
9
|
-
element.classes.toggle(className, shouldAdd);
|
|
10
|
-
}
|
|
11
5
|
|
|
12
6
|
/**
|
|
13
7
|
*
|
|
@@ -15,16 +9,18 @@ export function toggleElementClass(element, className, shouldAdd) {
|
|
|
15
9
|
* @param {Object} data
|
|
16
10
|
*/
|
|
17
11
|
export function bindClassAttribute(element, data) {
|
|
18
|
-
|
|
12
|
+
const classNames = Object.keys(data);
|
|
13
|
+
for(let i = 0, length = classNames.length; i < length; i++) {
|
|
14
|
+
const className = classNames[i];
|
|
19
15
|
const value = data[className];
|
|
20
16
|
if(value.__$isObservable) {
|
|
21
17
|
element.classes.toggle(className, value.val());
|
|
22
|
-
value.subscribe(
|
|
18
|
+
value.subscribe((shouldAdd) => element.classes.toggle(className, shouldAdd));
|
|
23
19
|
continue;
|
|
24
20
|
}
|
|
25
21
|
if(value.__$isObservableWhen) {
|
|
26
22
|
element.classes.toggle(className, value.isMath());
|
|
27
|
-
value.subscribe(
|
|
23
|
+
value.subscribe((shouldAdd) => element.classes.toggle(className, shouldAdd));
|
|
28
24
|
continue;
|
|
29
25
|
}
|
|
30
26
|
if(value.$hydrate) {
|
|
@@ -42,7 +38,9 @@ export function bindClassAttribute(element, data) {
|
|
|
42
38
|
* @param {Object} data
|
|
43
39
|
*/
|
|
44
40
|
export function bindStyleAttribute(element, data) {
|
|
45
|
-
|
|
41
|
+
const keys = Object.keys(data);
|
|
42
|
+
for(let i = 0, length = keys.length; i < length; i++) {
|
|
43
|
+
const styleName = keys[i];
|
|
46
44
|
const value = data[styleName];
|
|
47
45
|
if(value.__$isObservable) {
|
|
48
46
|
element.style[styleName] = value.val();
|
|
@@ -110,10 +108,12 @@ export function bindAttributeWithObservable(element, attributeName, value) {
|
|
|
110
108
|
export default function AttributesWrapper(element, attributes) {
|
|
111
109
|
|
|
112
110
|
Validator.validateAttributes(attributes);
|
|
111
|
+
const attributesKeys = Object.keys(attributes);
|
|
113
112
|
|
|
114
|
-
for(let
|
|
115
|
-
const
|
|
116
|
-
|
|
113
|
+
for(let i = 0, length = attributesKeys.length; i < length; i++) {
|
|
114
|
+
const originalAttributeName = attributesKeys[i];
|
|
115
|
+
const attributeName = originalAttributeName.toLowerCase();
|
|
116
|
+
let value = attributes[originalAttributeName];
|
|
117
117
|
if(value == null) {
|
|
118
118
|
continue;
|
|
119
119
|
}
|
|
@@ -5,12 +5,12 @@ import TemplateBinding from "../../../core/wrappers/TemplateBinding";
|
|
|
5
5
|
|
|
6
6
|
ObservableItem.prototype.bindNdClass = function(element, className) {
|
|
7
7
|
element.classes.toggle(className, this.val());
|
|
8
|
-
this.subscribe(
|
|
8
|
+
this.subscribe((shouldAdd) => element.classes.toggle(className, shouldAdd));
|
|
9
9
|
};
|
|
10
10
|
|
|
11
11
|
ObservableWhen.prototype.bindNdClass = function(element, className) {
|
|
12
12
|
element.classes.toggle(className, this.isMath());
|
|
13
|
-
this.subscribe(
|
|
13
|
+
this.subscribe((shouldAdd) => element.classes.toggle(className, shouldAdd));
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
TemplateBinding.prototype.bindNdClass = function(element, className) {
|