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