native-document 1.0.9 → 1.0.10
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/index.js
CHANGED
|
@@ -2,6 +2,7 @@ export { default as HtmlElementWrapper, ElementCreator } from './src/wrappers/Ht
|
|
|
2
2
|
|
|
3
3
|
import './src/utils/prototypes.js';
|
|
4
4
|
|
|
5
|
+
export * from './src/utils/plugins-manager';
|
|
5
6
|
export * from './src/utils/args-types';
|
|
6
7
|
export * from './src/data/Observable';
|
|
7
8
|
export * from './src/data/Store';
|
package/package.json
CHANGED
package/src/data/Observable.js
CHANGED
|
@@ -120,6 +120,26 @@ Observable.init = function(value) {
|
|
|
120
120
|
|
|
121
121
|
Observable.object = Observable.init;
|
|
122
122
|
Observable.json = Observable.init;
|
|
123
|
+
Observable.update = function($target, data) {
|
|
124
|
+
for(const key in data) {
|
|
125
|
+
const targetItem = $target[key];
|
|
126
|
+
const newValue = data[key];
|
|
127
|
+
|
|
128
|
+
if(Validator.isObservable(targetItem)) {
|
|
129
|
+
if(Validator.isArray(newValue)) {
|
|
130
|
+
Observable.update(targetItem, newValue);
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
targetItem.set(newValue);
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
136
|
+
if(Validator.isProxy(targetItem)) {
|
|
137
|
+
Observable.update(targetItem, newValue);
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
140
|
+
$target[key] = newValue;
|
|
141
|
+
}
|
|
142
|
+
};
|
|
123
143
|
/**
|
|
124
144
|
*
|
|
125
145
|
* @param {Array} target
|
package/src/utils/validator.js
CHANGED
|
@@ -70,7 +70,13 @@ const Validator = {
|
|
|
70
70
|
|
|
71
71
|
return children;
|
|
72
72
|
},
|
|
73
|
-
|
|
73
|
+
containsObservables(data) {
|
|
74
|
+
if(!data) {
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
return Validator.isObject(data)
|
|
78
|
+
&& Object.values(data).some(value => Validator.isObservable(value));
|
|
79
|
+
},
|
|
74
80
|
validateAttributes(attributes) {
|
|
75
81
|
if (!attributes || typeof attributes !== 'object') {
|
|
76
82
|
return attributes;
|
|
@@ -5,6 +5,7 @@ import DocumentObserver from "./DocumentObserver";
|
|
|
5
5
|
import Validator from "../utils/validator";
|
|
6
6
|
import DebugManager from "../utils/debug-manager";
|
|
7
7
|
import Anchor from "../elements/anchor";
|
|
8
|
+
import PluginsManager from "../utils/plugins-manager";
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
*
|
|
@@ -160,6 +161,11 @@ export const ElementCreator = {
|
|
|
160
161
|
HtmlElementEventsWrapper(element);
|
|
161
162
|
const item = (typeof customWrapper === 'function') ? customWrapper(element) : element;
|
|
162
163
|
addUtilsMethods(item);
|
|
164
|
+
|
|
165
|
+
PluginsManager.list().forEach(plugin => {
|
|
166
|
+
plugin?.element?.setup && plugin.element.setup(item, attributes);
|
|
167
|
+
});
|
|
168
|
+
|
|
163
169
|
return item;
|
|
164
170
|
}
|
|
165
171
|
};
|