@domql/element 2.5.197 → 2.5.200
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/cjs/create.js +43 -85
- package/dist/cjs/define.js +1 -2
- package/dist/cjs/extend.js +4 -8
- package/dist/cjs/index.js +3 -3
- package/dist/cjs/iterate.js +9 -18
- package/dist/cjs/methods/index.js +33 -66
- package/dist/cjs/methods/set.js +1 -2
- package/dist/cjs/methods/v2.js +6 -12
- package/dist/cjs/mixins/attr.js +4 -8
- package/dist/cjs/mixins/classList.js +8 -16
- package/dist/cjs/mixins/content.js +7 -14
- package/dist/cjs/mixins/data.js +2 -4
- package/dist/cjs/mixins/html.js +2 -4
- package/dist/cjs/mixins/scope.js +1 -2
- package/dist/cjs/mixins/state.js +2 -4
- package/dist/cjs/mixins/style.js +2 -4
- package/dist/cjs/mixins/text.js +3 -6
- package/dist/cjs/node.js +6 -12
- package/dist/cjs/props/create.js +6 -12
- package/dist/cjs/props/inherit.js +2 -4
- package/dist/cjs/props/update.js +3 -6
- package/dist/cjs/set.js +7 -14
- package/dist/cjs/update.js +24 -48
- package/dist/cjs/utils/applyParam.js +1 -2
- package/dist/cjs/utils/component.js +3 -6
- package/dist/cjs/utils/extendUtils.js +9 -18
- package/dist/cjs/utils/object.js +8 -16
- package/dist/cjs/utils/onlyResolveExtends.js +13 -26
- package/dist/cjs/utils/propEvents.js +2 -4
- package/dist/esm/create.js +43 -85
- package/dist/esm/define.js +1 -2
- package/dist/esm/extend.js +4 -8
- package/dist/esm/iterate.js +9 -18
- package/dist/esm/methods/index.js +33 -66
- package/dist/esm/methods/set.js +1 -2
- package/dist/esm/methods/v2.js +6 -12
- package/dist/esm/mixins/attr.js +4 -8
- package/dist/esm/mixins/classList.js +8 -16
- package/dist/esm/mixins/content.js +7 -14
- package/dist/esm/mixins/data.js +2 -4
- package/dist/esm/mixins/html.js +2 -4
- package/dist/esm/mixins/scope.js +1 -2
- package/dist/esm/mixins/state.js +2 -4
- package/dist/esm/mixins/style.js +2 -4
- package/dist/esm/mixins/text.js +3 -6
- package/dist/esm/node.js +6 -12
- package/dist/esm/props/create.js +6 -12
- package/dist/esm/props/inherit.js +2 -4
- package/dist/esm/props/update.js +3 -6
- package/dist/esm/set.js +7 -14
- package/dist/esm/update.js +24 -48
- package/dist/esm/utils/applyParam.js +1 -2
- package/dist/esm/utils/component.js +3 -6
- package/dist/esm/utils/extendUtils.js +9 -18
- package/dist/esm/utils/object.js +8 -16
- package/dist/esm/utils/onlyResolveExtends.js +13 -26
- package/dist/esm/utils/propEvents.js +2 -4
- package/package.json +6 -6
|
@@ -7,15 +7,12 @@ function spotByPath(path) {
|
|
|
7
7
|
const element = this;
|
|
8
8
|
const arr = [].concat(path);
|
|
9
9
|
let active = TREE[arr[0]];
|
|
10
|
-
if (!arr || !arr.length)
|
|
11
|
-
return console.log(arr, "on", element.key, "is undefined");
|
|
10
|
+
if (!arr || !arr.length) return console.log(arr, "on", element.key, "is undefined");
|
|
12
11
|
while (active.key === arr[0]) {
|
|
13
12
|
arr.shift();
|
|
14
|
-
if (!arr.length)
|
|
15
|
-
break;
|
|
13
|
+
if (!arr.length) break;
|
|
16
14
|
active = active[arr[0]];
|
|
17
|
-
if (!active)
|
|
18
|
-
return;
|
|
15
|
+
if (!active) return;
|
|
19
16
|
}
|
|
20
17
|
return active;
|
|
21
18
|
}
|
|
@@ -23,21 +20,15 @@ function lookup(param) {
|
|
|
23
20
|
const el = this;
|
|
24
21
|
let { parent } = el;
|
|
25
22
|
if (isFunction(param)) {
|
|
26
|
-
if (parent.state && param(parent, parent.state, parent.context))
|
|
27
|
-
|
|
28
|
-
else
|
|
29
|
-
return parent.lookup(param);
|
|
30
|
-
else
|
|
31
|
-
return;
|
|
23
|
+
if (parent.state && param(parent, parent.state, parent.context)) return parent;
|
|
24
|
+
else if (parent.parent) return parent.lookup(param);
|
|
25
|
+
else return;
|
|
32
26
|
}
|
|
33
|
-
if (el[param])
|
|
34
|
-
return el[param];
|
|
27
|
+
if (el[param]) return el[param];
|
|
35
28
|
while (parent.param !== param) {
|
|
36
|
-
if (parent[param])
|
|
37
|
-
return parent[param];
|
|
29
|
+
if (parent[param]) return parent[param];
|
|
38
30
|
parent = parent.parent;
|
|
39
|
-
if (!parent)
|
|
40
|
-
return;
|
|
31
|
+
if (!parent) return;
|
|
41
32
|
}
|
|
42
33
|
return parent;
|
|
43
34
|
}
|
|
@@ -49,8 +40,7 @@ function lookdown(param) {
|
|
|
49
40
|
for (let i = 0; i < children.length; i++) {
|
|
50
41
|
const v = children[i];
|
|
51
42
|
const childElem = el[v];
|
|
52
|
-
if (v === param)
|
|
53
|
-
return childElem;
|
|
43
|
+
if (v === param) return childElem;
|
|
54
44
|
else if (isFunction(param)) {
|
|
55
45
|
const exec = param(childElem, childElem.state, childElem.context);
|
|
56
46
|
if (childElem.state && exec) {
|
|
@@ -58,8 +48,7 @@ function lookdown(param) {
|
|
|
58
48
|
}
|
|
59
49
|
}
|
|
60
50
|
const lookdown2 = (_a = childElem == null ? void 0 : childElem.lookdown) == null ? void 0 : _a.call(childElem, param);
|
|
61
|
-
if (lookdown2)
|
|
62
|
-
return lookdown2;
|
|
51
|
+
if (lookdown2) return lookdown2;
|
|
63
52
|
}
|
|
64
53
|
}
|
|
65
54
|
function lookdownAll(param, results = []) {
|
|
@@ -70,12 +59,10 @@ function lookdownAll(param, results = []) {
|
|
|
70
59
|
for (let i = 0; i < children.length; i++) {
|
|
71
60
|
const v = children[i];
|
|
72
61
|
const childElem = el[v];
|
|
73
|
-
if (v === param)
|
|
74
|
-
results.push(childElem);
|
|
62
|
+
if (v === param) results.push(childElem);
|
|
75
63
|
else if (isFunction(param)) {
|
|
76
64
|
const exec = param(childElem, childElem.state, childElem.context);
|
|
77
|
-
if (childElem.state && exec)
|
|
78
|
-
results.push(childElem);
|
|
65
|
+
if (childElem.state && exec) results.push(childElem);
|
|
79
66
|
}
|
|
80
67
|
(_a = childElem == null ? void 0 : childElem.lookdownAll) == null ? void 0 : _a.call(childElem, param, results);
|
|
81
68
|
}
|
|
@@ -84,32 +71,26 @@ function lookdownAll(param, results = []) {
|
|
|
84
71
|
function setNodeStyles(params = {}) {
|
|
85
72
|
var _a;
|
|
86
73
|
const el = this;
|
|
87
|
-
if (!((_a = el.node) == null ? void 0 : _a.style))
|
|
88
|
-
return;
|
|
74
|
+
if (!((_a = el.node) == null ? void 0 : _a.style)) return;
|
|
89
75
|
for (const param in params) {
|
|
90
76
|
const value = params[param];
|
|
91
77
|
const childElem = el[param];
|
|
92
|
-
if (isObject(value) && childElem)
|
|
93
|
-
|
|
94
|
-
else
|
|
95
|
-
el.node.style[param] = value;
|
|
78
|
+
if (isObject(value) && childElem) setNodeStyles.call(childElem, value);
|
|
79
|
+
else el.node.style[param] = value;
|
|
96
80
|
}
|
|
97
81
|
return el;
|
|
98
82
|
}
|
|
99
83
|
function remove(opts) {
|
|
100
84
|
const element = this;
|
|
101
85
|
const beforeRemoveReturns = triggerEventOn("beforeRemove", element, opts);
|
|
102
|
-
if (beforeRemoveReturns === false)
|
|
103
|
-
|
|
104
|
-
if (isFunction(element.node.remove))
|
|
105
|
-
element.node.remove();
|
|
86
|
+
if (beforeRemoveReturns === false) return element;
|
|
87
|
+
if (isFunction(element.node.remove)) element.node.remove();
|
|
106
88
|
else if (!isProduction()) {
|
|
107
89
|
console.warn("This item cant be removed");
|
|
108
90
|
element.log();
|
|
109
91
|
}
|
|
110
92
|
delete element.parent[element.key];
|
|
111
|
-
if (element.parent.__ref)
|
|
112
|
-
element.parent.__ref.__children = removeValueFromArray(element.parent.__ref.__children, element.key);
|
|
93
|
+
if (element.parent.__ref) element.parent.__ref.__children = removeValueFromArray(element.parent.__ref.__children, element.key);
|
|
113
94
|
triggerEventOn("remove", element, opts);
|
|
114
95
|
}
|
|
115
96
|
function get(param) {
|
|
@@ -118,8 +99,7 @@ function get(param) {
|
|
|
118
99
|
}
|
|
119
100
|
function setProps(param, options) {
|
|
120
101
|
const element = this;
|
|
121
|
-
if (!param || !element.props)
|
|
122
|
-
return;
|
|
102
|
+
if (!param || !element.props) return;
|
|
123
103
|
element.update({ props: param }, options);
|
|
124
104
|
return element;
|
|
125
105
|
}
|
|
@@ -146,23 +126,19 @@ function parse(excl = []) {
|
|
|
146
126
|
const obj = {};
|
|
147
127
|
const keyList = keys.call(element);
|
|
148
128
|
keyList.forEach((v) => {
|
|
149
|
-
if (excl.includes(v))
|
|
150
|
-
return;
|
|
129
|
+
if (excl.includes(v)) return;
|
|
151
130
|
const val = element[v];
|
|
152
131
|
if (v === "state") {
|
|
153
|
-
if (element.__ref && !element.__ref.__hasRootState)
|
|
154
|
-
return;
|
|
132
|
+
if (element.__ref && !element.__ref.__hasRootState) return;
|
|
155
133
|
const parsedVal = isFunction(val && val.parse) ? val.parse() : val;
|
|
156
134
|
obj[v] = isFunction(parsedVal) ? parsedVal : JSON.parse(JSON.stringify(parsedVal || {}));
|
|
157
135
|
} else if (v === "scope") {
|
|
158
|
-
if (element.__ref && !element.__ref.__hasRootScope)
|
|
159
|
-
return;
|
|
136
|
+
if (element.__ref && !element.__ref.__hasRootScope) return;
|
|
160
137
|
obj[v] = JSON.parse(JSON.stringify(val || {}));
|
|
161
138
|
} else if (v === "props") {
|
|
162
139
|
const { __element, update, ...props } = element[v];
|
|
163
140
|
obj[v] = props;
|
|
164
|
-
} else if (isDefined(val) && Object.hasOwnProperty.call(element, v))
|
|
165
|
-
obj[v] = val;
|
|
141
|
+
} else if (isDefined(val) && Object.hasOwnProperty.call(element, v)) obj[v] = val;
|
|
166
142
|
});
|
|
167
143
|
return obj;
|
|
168
144
|
}
|
|
@@ -170,8 +146,7 @@ function parseDeep(excl = []) {
|
|
|
170
146
|
const element = this;
|
|
171
147
|
const obj = parse.call(element, excl);
|
|
172
148
|
for (const v in obj) {
|
|
173
|
-
if (excl.includes(v))
|
|
174
|
-
return;
|
|
149
|
+
if (excl.includes(v)) return;
|
|
175
150
|
if (isObjectLike(obj[v])) {
|
|
176
151
|
obj[v] = parseDeep.call(obj[v], excl);
|
|
177
152
|
}
|
|
@@ -179,8 +154,7 @@ function parseDeep(excl = []) {
|
|
|
179
154
|
return obj;
|
|
180
155
|
}
|
|
181
156
|
function verbose(...args) {
|
|
182
|
-
if (ENV !== "test" && ENV !== "development")
|
|
183
|
-
return;
|
|
157
|
+
if (ENV !== "test" && ENV !== "development") return;
|
|
184
158
|
const element = this;
|
|
185
159
|
const { __ref: ref } = element;
|
|
186
160
|
console.groupCollapsed(element.key);
|
|
@@ -209,10 +183,8 @@ function warn(...params) {
|
|
|
209
183
|
function error(...params) {
|
|
210
184
|
var _a, _b;
|
|
211
185
|
if (ENV === "test" || ENV === "development") {
|
|
212
|
-
if ((_a = params[params.length - 1]) == null ? void 0 : _a.debugger)
|
|
213
|
-
|
|
214
|
-
if ((_b = params[params.length - 1]) == null ? void 0 : _b.verbose)
|
|
215
|
-
verbose.call(this);
|
|
186
|
+
if ((_a = params[params.length - 1]) == null ? void 0 : _a.debugger) debugger;
|
|
187
|
+
if ((_b = params[params.length - 1]) == null ? void 0 : _b.verbose) verbose.call(this);
|
|
216
188
|
throw new Error(...params);
|
|
217
189
|
}
|
|
218
190
|
}
|
|
@@ -228,17 +200,14 @@ function previousElement(el) {
|
|
|
228
200
|
const element = el || this;
|
|
229
201
|
const { key, parent } = element;
|
|
230
202
|
const { __children } = parent.__ref;
|
|
231
|
-
if (!__children)
|
|
232
|
-
return;
|
|
203
|
+
if (!__children) return;
|
|
233
204
|
const currentIndex = __children.indexOf(key);
|
|
234
205
|
return parent[__children[currentIndex - 1]];
|
|
235
206
|
}
|
|
236
207
|
function variables(obj = {}) {
|
|
237
208
|
const element = this;
|
|
238
|
-
if (!element.data)
|
|
239
|
-
|
|
240
|
-
if (!element.data.varCaches)
|
|
241
|
-
element.data.varCaches = {};
|
|
209
|
+
if (!element.data) element.data = {};
|
|
210
|
+
if (!element.data.varCaches) element.data.varCaches = {};
|
|
242
211
|
const varCaches = element.data.varCaches;
|
|
243
212
|
const changes = {};
|
|
244
213
|
let changed;
|
|
@@ -250,8 +219,7 @@ function variables(obj = {}) {
|
|
|
250
219
|
}
|
|
251
220
|
return {
|
|
252
221
|
changed: (cb) => {
|
|
253
|
-
if (!changed)
|
|
254
|
-
return;
|
|
222
|
+
if (!changed) return;
|
|
255
223
|
const returns = cb(changes, deepClone(varCaches));
|
|
256
224
|
for (const key in changes) {
|
|
257
225
|
varCaches[key] = changes[key];
|
|
@@ -259,8 +227,7 @@ function variables(obj = {}) {
|
|
|
259
227
|
return returns;
|
|
260
228
|
},
|
|
261
229
|
timeout: (cb, timeout) => {
|
|
262
|
-
if (!changed)
|
|
263
|
-
return;
|
|
230
|
+
if (!changed) return;
|
|
264
231
|
const t = setTimeout(() => {
|
|
265
232
|
cb(changes);
|
|
266
233
|
clearTimeout(t);
|
package/dist/esm/methods/set.js
CHANGED
|
@@ -52,8 +52,7 @@ const addMethods = (element, parent, options = {}) => {
|
|
|
52
52
|
error,
|
|
53
53
|
call
|
|
54
54
|
};
|
|
55
|
-
if (element.context.methods)
|
|
56
|
-
(options.strict ? merge : overwrite)(proto, element.context.methods);
|
|
55
|
+
if (element.context.methods) (options.strict ? merge : overwrite)(proto, element.context.methods);
|
|
57
56
|
Object.setPrototypeOf(element, proto);
|
|
58
57
|
};
|
|
59
58
|
export {
|
package/dist/esm/methods/v2.js
CHANGED
|
@@ -17,19 +17,15 @@ const parse = function(excl = []) {
|
|
|
17
17
|
const obj = {};
|
|
18
18
|
const keyList = keys.call(element);
|
|
19
19
|
keyList.forEach((v) => {
|
|
20
|
-
if (excl.includes(v))
|
|
21
|
-
return;
|
|
20
|
+
if (excl.includes(v)) return;
|
|
22
21
|
let val = element[v];
|
|
23
22
|
if (v === "state") {
|
|
24
|
-
if (element.__ref && element.__ref.__hasRootState)
|
|
25
|
-
|
|
26
|
-
if (isFunction(val && val.parse))
|
|
27
|
-
val = val.parse();
|
|
23
|
+
if (element.__ref && element.__ref.__hasRootState) return;
|
|
24
|
+
if (isFunction(val && val.parse)) val = val.parse();
|
|
28
25
|
} else if (v === "props") {
|
|
29
26
|
const { __element, update, ...props } = element[v];
|
|
30
27
|
obj[v] = props;
|
|
31
|
-
} else if (isDefined(val))
|
|
32
|
-
obj[v] = val;
|
|
28
|
+
} else if (isDefined(val)) obj[v] = val;
|
|
33
29
|
});
|
|
34
30
|
return obj;
|
|
35
31
|
};
|
|
@@ -37,8 +33,7 @@ const parseDeep = function(excl = []) {
|
|
|
37
33
|
const element = this;
|
|
38
34
|
const obj = parse.call(element, excl);
|
|
39
35
|
for (const v in obj) {
|
|
40
|
-
if (excl.includes(v))
|
|
41
|
-
return;
|
|
36
|
+
if (excl.includes(v)) return;
|
|
42
37
|
if (isObjectLike(obj[v])) {
|
|
43
38
|
obj[v] = parseDeep.call(obj[v], excl);
|
|
44
39
|
}
|
|
@@ -73,8 +68,7 @@ const previousElement = function(el) {
|
|
|
73
68
|
const element = el || this;
|
|
74
69
|
const { key, parent } = element;
|
|
75
70
|
const { __children } = parent.__ref;
|
|
76
|
-
if (!__children)
|
|
77
|
-
return;
|
|
71
|
+
if (!__children) return;
|
|
78
72
|
const currentIndex = __children.indexOf(key);
|
|
79
73
|
return parent[__children[currentIndex - 1]];
|
|
80
74
|
};
|
package/dist/esm/mixins/attr.js
CHANGED
|
@@ -4,17 +4,13 @@ import { deepMerge } from "../utils/index.js";
|
|
|
4
4
|
function attr(params, element, node) {
|
|
5
5
|
const { __ref: ref, props } = element;
|
|
6
6
|
const { __attr } = ref;
|
|
7
|
-
if (isNot("object"))
|
|
8
|
-
report("HTMLInvalidAttr", params);
|
|
7
|
+
if (isNot("object")) report("HTMLInvalidAttr", params);
|
|
9
8
|
if (params) {
|
|
10
|
-
if (props.attr)
|
|
11
|
-
deepMerge(params, props.attr);
|
|
9
|
+
if (props.attr) deepMerge(params, props.attr);
|
|
12
10
|
for (const attr2 in params) {
|
|
13
11
|
const val = exec(params[attr2], element);
|
|
14
|
-
if (val !== false && !isUndefined(val) && !isNull(val) && node.setAttribute)
|
|
15
|
-
|
|
16
|
-
else if (node.removeAttribute)
|
|
17
|
-
node.removeAttribute(attr2);
|
|
12
|
+
if (val !== false && !isUndefined(val) && !isNull(val) && node.setAttribute) node.setAttribute(attr2, val);
|
|
13
|
+
else if (node.removeAttribute) node.removeAttribute(attr2);
|
|
18
14
|
__attr[attr2] = val;
|
|
19
15
|
}
|
|
20
16
|
}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { exec, isObject, isString } from "@domql/utils";
|
|
2
2
|
const assignKeyAsClassname = (element) => {
|
|
3
3
|
const { key } = element;
|
|
4
|
-
if (element.class === true)
|
|
5
|
-
element.class = key;
|
|
4
|
+
if (element.class === true) element.class = key;
|
|
6
5
|
else if (!element.class && typeof key === "string" && key.charAt(0) === "_" && key.charAt(1) !== "_") {
|
|
7
6
|
element.class = key.slice(1);
|
|
8
7
|
}
|
|
@@ -11,10 +10,8 @@ const classify = (obj, element) => {
|
|
|
11
10
|
let className = "";
|
|
12
11
|
for (const item in obj) {
|
|
13
12
|
const param = obj[item];
|
|
14
|
-
if (typeof param === "boolean" && param)
|
|
15
|
-
|
|
16
|
-
else if (typeof param === "string")
|
|
17
|
-
className += ` ${param}`;
|
|
13
|
+
if (typeof param === "boolean" && param) className += ` ${item}`;
|
|
14
|
+
else if (typeof param === "string") className += ` ${param}`;
|
|
18
15
|
else if (typeof param === "function") {
|
|
19
16
|
className += ` ${exec(param, element)}`;
|
|
20
17
|
}
|
|
@@ -22,18 +19,13 @@ const classify = (obj, element) => {
|
|
|
22
19
|
return className;
|
|
23
20
|
};
|
|
24
21
|
const classList = (params, element) => {
|
|
25
|
-
if (!params)
|
|
26
|
-
return;
|
|
22
|
+
if (!params) return;
|
|
27
23
|
const { key } = element;
|
|
28
|
-
if (params === true)
|
|
29
|
-
|
|
30
|
-
if (
|
|
31
|
-
params = element.class = { default: params };
|
|
32
|
-
if (isObject(params))
|
|
33
|
-
params = classify(params, element);
|
|
24
|
+
if (params === true) params = element.class = { key };
|
|
25
|
+
if (isString(params)) params = element.class = { default: params };
|
|
26
|
+
if (isObject(params)) params = classify(params, element);
|
|
34
27
|
const className = params.replace(/\s+/g, " ").trim();
|
|
35
|
-
if (element.ref)
|
|
36
|
-
element.ref.class = className;
|
|
28
|
+
if (element.ref) element.ref.class = className;
|
|
37
29
|
return className;
|
|
38
30
|
};
|
|
39
31
|
const applyClassListOnNode = (params, element, node) => {
|
|
@@ -4,33 +4,26 @@ const updateContent = function(params, options) {
|
|
|
4
4
|
const element = this;
|
|
5
5
|
const ref = element.__ref;
|
|
6
6
|
const contentKey = ref.contentElementKey;
|
|
7
|
-
if (!element[contentKey])
|
|
8
|
-
|
|
9
|
-
if (element[contentKey].update)
|
|
10
|
-
element[contentKey].update(params, options);
|
|
7
|
+
if (!element[contentKey]) return;
|
|
8
|
+
if (element[contentKey].update) element[contentKey].update(params, options);
|
|
11
9
|
};
|
|
12
10
|
const removeContent = function(el, opts = {}) {
|
|
13
11
|
const element = el || this;
|
|
14
12
|
const { __ref: ref } = element;
|
|
15
13
|
const contentElementKey = setContentKey(element, opts);
|
|
16
|
-
if (opts.contentElementKey !== "content")
|
|
17
|
-
opts.contentElementKey = "content";
|
|
14
|
+
if (opts.contentElementKey !== "content") opts.contentElementKey = "content";
|
|
18
15
|
if (element[contentElementKey]) {
|
|
19
16
|
if (element[contentElementKey].node && element.node) {
|
|
20
|
-
if (element[contentElementKey].tag === "fragment")
|
|
21
|
-
element.node.innerHTML = "";
|
|
17
|
+
if (element[contentElementKey].tag === "fragment") element.node.innerHTML = "";
|
|
22
18
|
else {
|
|
23
19
|
const contentNode = element[contentElementKey].node;
|
|
24
|
-
if (contentNode.parentNode === element.node)
|
|
25
|
-
element.node.removeChild(element[contentElementKey].node);
|
|
20
|
+
if (contentNode.parentNode === element.node) element.node.removeChild(element[contentElementKey].node);
|
|
26
21
|
}
|
|
27
22
|
}
|
|
28
23
|
const { __cached } = ref;
|
|
29
24
|
if (__cached && __cached[contentElementKey]) {
|
|
30
|
-
if (__cached[contentElementKey].tag === "fragment")
|
|
31
|
-
|
|
32
|
-
else if (__cached[contentElementKey] && isFunction(__cached[contentElementKey].remove))
|
|
33
|
-
__cached[contentElementKey].remove();
|
|
25
|
+
if (__cached[contentElementKey].tag === "fragment") __cached[contentElementKey].parent.node.innerHTML = "";
|
|
26
|
+
else if (__cached[contentElementKey] && isFunction(__cached[contentElementKey].remove)) __cached[contentElementKey].remove();
|
|
34
27
|
}
|
|
35
28
|
delete element[contentElementKey];
|
|
36
29
|
}
|
package/dist/esm/mixins/data.js
CHANGED
|
@@ -2,11 +2,9 @@ import { exec, isObject, deepMerge } from "@domql/utils";
|
|
|
2
2
|
import { report } from "@domql/report";
|
|
3
3
|
function data(params, element, node) {
|
|
4
4
|
if (params) {
|
|
5
|
-
if (element.props.data)
|
|
6
|
-
deepMerge(params, element.props.data);
|
|
5
|
+
if (element.props.data) deepMerge(params, element.props.data);
|
|
7
6
|
if (params.showOnNode) {
|
|
8
|
-
if (!isObject(params))
|
|
9
|
-
report("HTMLInvalidData", params);
|
|
7
|
+
if (!isObject(params)) report("HTMLInvalidData", params);
|
|
10
8
|
for (const dataset in params) {
|
|
11
9
|
if (dataset !== "showOnNode") {
|
|
12
10
|
node.dataset[dataset] = exec(params[dataset], element);
|
package/dist/esm/mixins/html.js
CHANGED
|
@@ -4,10 +4,8 @@ function html(param, element, node) {
|
|
|
4
4
|
const prop = exec(param, element) || exec((_a = element == null ? void 0 : element.props) == null ? void 0 : _a.html, element);
|
|
5
5
|
const { __ref } = element;
|
|
6
6
|
if (prop !== __ref.__html) {
|
|
7
|
-
if (node.nodeName === "SVG")
|
|
8
|
-
|
|
9
|
-
else
|
|
10
|
-
node.innerHTML = prop;
|
|
7
|
+
if (node.nodeName === "SVG") node.textContent = prop;
|
|
8
|
+
else node.innerHTML = prop;
|
|
11
9
|
__ref.__html = prop;
|
|
12
10
|
}
|
|
13
11
|
}
|
package/dist/esm/mixins/scope.js
CHANGED
package/dist/esm/mixins/state.js
CHANGED
|
@@ -4,10 +4,8 @@ function state(params, element, node) {
|
|
|
4
4
|
const state2 = exec(params, element);
|
|
5
5
|
if (isObject(state2)) {
|
|
6
6
|
for (const param in state2) {
|
|
7
|
-
if (IGNORE_STATE_PARAMS.includes(param))
|
|
8
|
-
|
|
9
|
-
if (!Object.hasOwnProperty.call(state2, param))
|
|
10
|
-
continue;
|
|
7
|
+
if (IGNORE_STATE_PARAMS.includes(param)) continue;
|
|
8
|
+
if (!Object.hasOwnProperty.call(state2, param)) continue;
|
|
11
9
|
}
|
|
12
10
|
}
|
|
13
11
|
return element;
|
package/dist/esm/mixins/style.js
CHANGED
|
@@ -2,10 +2,8 @@ import { isObject, map } from "@domql/utils";
|
|
|
2
2
|
import { report } from "@domql/report";
|
|
3
3
|
function style(params, element, node) {
|
|
4
4
|
if (params) {
|
|
5
|
-
if (isObject(params))
|
|
6
|
-
|
|
7
|
-
else
|
|
8
|
-
report("HTMLInvalidStyles", params);
|
|
5
|
+
if (isObject(params)) map(node.style, params, element);
|
|
6
|
+
else report("HTMLInvalidStyles", params);
|
|
9
7
|
}
|
|
10
8
|
}
|
|
11
9
|
var style_default = style;
|
package/dist/esm/mixins/text.js
CHANGED
|
@@ -12,13 +12,10 @@ function text(param, element, node) {
|
|
|
12
12
|
node.nodeValue = prop;
|
|
13
13
|
} else if (param !== void 0 || param !== null) {
|
|
14
14
|
if (element.__text) {
|
|
15
|
-
if (element.__text.text === prop)
|
|
16
|
-
return;
|
|
15
|
+
if (element.__text.text === prop) return;
|
|
17
16
|
element.__text.text = prop;
|
|
18
|
-
if (element.__text.node)
|
|
19
|
-
|
|
20
|
-
} else
|
|
21
|
-
create({ tag: "string", text: prop }, element, "__text");
|
|
17
|
+
if (element.__text.node) element.__text.node.nodeValue = prop;
|
|
18
|
+
} else create({ tag: "string", text: prop }, element, "__text");
|
|
22
19
|
}
|
|
23
20
|
}
|
|
24
21
|
var text_default = text;
|
package/dist/esm/node.js
CHANGED
|
@@ -17,18 +17,15 @@ const createNode = async (element, options) => {
|
|
|
17
17
|
let isNewNode;
|
|
18
18
|
if (!node) {
|
|
19
19
|
isNewNode = true;
|
|
20
|
-
if (!ref.__if)
|
|
21
|
-
return element;
|
|
20
|
+
if (!ref.__if) return element;
|
|
22
21
|
if (tag === "shadow") {
|
|
23
22
|
node = element.node = element.parent.node.attachShadow({ mode: "open" });
|
|
24
|
-
} else
|
|
25
|
-
node = element.node = cacheNode(element);
|
|
23
|
+
} else node = element.node = cacheNode(element);
|
|
26
24
|
triggerEventOn("attachNode", element, options);
|
|
27
25
|
}
|
|
28
26
|
if (ENV === "test" || ENV === "development" || options.alowRefReference) {
|
|
29
27
|
node.ref = element;
|
|
30
|
-
if (isFunction(node.setAttribute))
|
|
31
|
-
node.setAttribute("key", element.key);
|
|
28
|
+
if (isFunction(node.setAttribute)) node.setAttribute("key", element.key);
|
|
32
29
|
}
|
|
33
30
|
throughExecProps(element);
|
|
34
31
|
throughInitialDefine(element);
|
|
@@ -41,10 +38,8 @@ const createNode = async (element, options) => {
|
|
|
41
38
|
}
|
|
42
39
|
for (const param in element) {
|
|
43
40
|
const value = element[param];
|
|
44
|
-
if (!Object.hasOwnProperty.call(element, param))
|
|
45
|
-
|
|
46
|
-
if (isUndefined(value) || isMethod(param, element) || isVariant(param) || isObject(REGISTRY[param]))
|
|
47
|
-
continue;
|
|
41
|
+
if (!Object.hasOwnProperty.call(element, param)) continue;
|
|
42
|
+
if (isUndefined(value) || isMethod(param, element) || isVariant(param) || isObject(REGISTRY[param])) continue;
|
|
48
43
|
const isElement = applyParam(param, element, options);
|
|
49
44
|
if (isElement) {
|
|
50
45
|
const { hasDefine, hasContextDefine } = isElement;
|
|
@@ -59,8 +54,7 @@ const createNode = async (element, options) => {
|
|
|
59
54
|
triggerEventOn("lazyLoad", element, options);
|
|
60
55
|
}
|
|
61
56
|
});
|
|
62
|
-
} else
|
|
63
|
-
await createAsync();
|
|
57
|
+
} else await createAsync();
|
|
64
58
|
}
|
|
65
59
|
}
|
|
66
60
|
}
|
package/dist/esm/props/create.js
CHANGED
|
@@ -4,16 +4,12 @@ import { inheritParentProps } from "./inherit.js";
|
|
|
4
4
|
const createPropsStack = (element, parent) => {
|
|
5
5
|
const { props, __ref: ref } = element;
|
|
6
6
|
const propsStack = ref.__props = inheritParentProps(element, parent);
|
|
7
|
-
if (isObject(props))
|
|
8
|
-
|
|
9
|
-
else if (props
|
|
10
|
-
propsStack.push(parent.props);
|
|
11
|
-
else if (props)
|
|
12
|
-
propsStack.push(props);
|
|
7
|
+
if (isObject(props)) propsStack.push(props);
|
|
8
|
+
else if (props === "inherit" && parent.props) propsStack.push(parent.props);
|
|
9
|
+
else if (props) propsStack.push(props);
|
|
13
10
|
if (isArray(ref.__extend)) {
|
|
14
11
|
ref.__extend.forEach((extend) => {
|
|
15
|
-
if (extend.props && extend.props !== props)
|
|
16
|
-
propsStack.push(extend.props);
|
|
12
|
+
if (extend.props && extend.props !== props) propsStack.push(extend.props);
|
|
17
13
|
});
|
|
18
14
|
}
|
|
19
15
|
ref.__props = propsStack;
|
|
@@ -23,8 +19,7 @@ const syncProps = (props, element, opts) => {
|
|
|
23
19
|
element.props = {};
|
|
24
20
|
const mergedProps = {};
|
|
25
21
|
props.forEach((v) => {
|
|
26
|
-
if (IGNORE_PROPS_PARAMS.includes(v))
|
|
27
|
-
return;
|
|
22
|
+
if (IGNORE_PROPS_PARAMS.includes(v)) return;
|
|
28
23
|
let execProps;
|
|
29
24
|
try {
|
|
30
25
|
execProps = exec(v, element);
|
|
@@ -54,8 +49,7 @@ const createProps = function(element, parent, options) {
|
|
|
54
49
|
element.props = {};
|
|
55
50
|
}
|
|
56
51
|
};
|
|
57
|
-
if (ref.__if)
|
|
58
|
-
applyProps();
|
|
52
|
+
if (ref.__if) applyProps();
|
|
59
53
|
else {
|
|
60
54
|
try {
|
|
61
55
|
applyProps();
|
|
@@ -15,8 +15,7 @@ const inheritParentProps = (element, parent) => {
|
|
|
15
15
|
if (matchParent) {
|
|
16
16
|
if (matchParentIsString) {
|
|
17
17
|
const inheritedStringExists = propsStack.filter((v) => v.inheritedString)[0];
|
|
18
|
-
if (inheritedStringExists)
|
|
19
|
-
inheritedStringExists.inheritedString = matchParent;
|
|
18
|
+
if (inheritedStringExists) inheritedStringExists.inheritedString = matchParent;
|
|
20
19
|
else {
|
|
21
20
|
propsStack = [].concat(objectizeStringProperty(matchParent), propsStack);
|
|
22
21
|
}
|
|
@@ -24,8 +23,7 @@ const inheritParentProps = (element, parent) => {
|
|
|
24
23
|
propsStack.push(objectizeStringProperty(matchParent));
|
|
25
24
|
}
|
|
26
25
|
}
|
|
27
|
-
if (matchParentChildProps && !((_a = element == null ? void 0 : element.props) == null ? void 0 : _a.ignoreChildProps))
|
|
28
|
-
propsStack.push(matchParentChildProps);
|
|
26
|
+
if (matchParentChildProps && !((_a = element == null ? void 0 : element.props) == null ? void 0 : _a.ignoreChildProps)) propsStack.push(matchParentChildProps);
|
|
29
27
|
return propsStack;
|
|
30
28
|
};
|
|
31
29
|
export {
|
package/dist/esm/props/update.js
CHANGED
|
@@ -4,12 +4,9 @@ const updateProps = (newProps, element, parent) => {
|
|
|
4
4
|
const { __ref } = element;
|
|
5
5
|
let propsStack = __ref.__props;
|
|
6
6
|
const parentProps = inheritParentProps(element, parent);
|
|
7
|
-
if (parentProps.length)
|
|
8
|
-
|
|
9
|
-
if (
|
|
10
|
-
propsStack = __ref.__props = [].concat(newProps, propsStack);
|
|
11
|
-
if (propsStack)
|
|
12
|
-
syncProps(propsStack, element);
|
|
7
|
+
if (parentProps.length) propsStack = __ref.__props = [].concat(parentProps, propsStack);
|
|
8
|
+
if (newProps) propsStack = __ref.__props = [].concat(newProps, propsStack);
|
|
9
|
+
if (propsStack) syncProps(propsStack, element);
|
|
13
10
|
return element;
|
|
14
11
|
};
|
|
15
12
|
export {
|
package/dist/esm/set.js
CHANGED
|
@@ -5,8 +5,7 @@ import { registry } from "./mixins/index.js";
|
|
|
5
5
|
import { removeContent } from "./mixins/content.js";
|
|
6
6
|
import { triggerEventOn, triggerEventOnUpdate } from "@domql/event";
|
|
7
7
|
const resetElement = async (params, element, options) => {
|
|
8
|
-
if (!options.preventRemove)
|
|
9
|
-
removeContent(element, options);
|
|
8
|
+
if (!options.preventRemove) removeContent(element, options);
|
|
10
9
|
const { __ref: ref } = element;
|
|
11
10
|
await create(params, element, ref.contentElementKey || "content", {
|
|
12
11
|
ignoreChildExtend: true,
|
|
@@ -32,24 +31,19 @@ const set = async function(params, options = {}, el) {
|
|
|
32
31
|
const __contentRef = content && content.__ref;
|
|
33
32
|
const lazyLoad = element.props && element.props.lazyLoad;
|
|
34
33
|
const hasCollection = element.$collection || element.$stateCollection || element.$propsCollection;
|
|
35
|
-
if (options.preventContentUpdate === true && !hasCollection)
|
|
36
|
-
return;
|
|
34
|
+
if (options.preventContentUpdate === true && !hasCollection) return;
|
|
37
35
|
if (ref.__noCollectionDifference || __contentRef && __contentRef.__cached && deepContains(params, content)) {
|
|
38
36
|
if (!options.preventBeforeUpdateListener && !options.preventListeners) {
|
|
39
37
|
const beforeUpdateReturns = await triggerEventOnUpdate("beforeUpdate", params, element, options);
|
|
40
|
-
if (beforeUpdateReturns === false)
|
|
41
|
-
return element;
|
|
38
|
+
if (beforeUpdateReturns === false) return element;
|
|
42
39
|
}
|
|
43
|
-
if (content == null ? void 0 : content.update)
|
|
44
|
-
|
|
45
|
-
if (!options.preventUpdateListener)
|
|
46
|
-
await triggerEventOn("update", element, options);
|
|
40
|
+
if (content == null ? void 0 : content.update) content.update();
|
|
41
|
+
if (!options.preventUpdateListener) await triggerEventOn("update", element, options);
|
|
47
42
|
return;
|
|
48
43
|
}
|
|
49
44
|
if (params) {
|
|
50
45
|
let { childExtend, props } = params;
|
|
51
|
-
if (!props)
|
|
52
|
-
props = params.props = {};
|
|
46
|
+
if (!props) props = params.props = {};
|
|
53
47
|
if (!childExtend && element.childExtend) {
|
|
54
48
|
params.childExtend = element.childExtend;
|
|
55
49
|
props.ignoreChildExtend = true;
|
|
@@ -65,8 +59,7 @@ const set = async function(params, options = {}, el) {
|
|
|
65
59
|
triggerEventOn("lazyLoad", element, options);
|
|
66
60
|
}
|
|
67
61
|
});
|
|
68
|
-
} else
|
|
69
|
-
await resetElement(params, element, options);
|
|
62
|
+
} else await resetElement(params, element, options);
|
|
70
63
|
}
|
|
71
64
|
return element;
|
|
72
65
|
};
|