@domql/element 2.5.203 → 2.5.206
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 +9 -16
- 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 +8 -14
- 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 +9 -16
- package/dist/cjs/update.js +32 -56
- package/dist/cjs/utils/applyParam.js +3 -4
- 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 +9 -16
- 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 +8 -14
- 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 +9 -16
- package/dist/esm/update.js +32 -56
- package/dist/esm/utils/applyParam.js +3 -4
- 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/mixins/content.js +2 -2
- package/node.js +2 -2
- package/package.json +3 -3
- package/set.js +3 -3
- package/update.js +9 -9
- package/utils/applyParam.js +2 -2
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,
|
|
@@ -15,9 +14,9 @@ const resetElement = async (params, element, options) => {
|
|
|
15
14
|
...options
|
|
16
15
|
});
|
|
17
16
|
};
|
|
18
|
-
const reset = (options) => {
|
|
17
|
+
const reset = async (options) => {
|
|
19
18
|
const element = void 0;
|
|
20
|
-
create(element, element.parent, void 0, {
|
|
19
|
+
await create(element, element.parent, void 0, {
|
|
21
20
|
ignoreChildExtend: true,
|
|
22
21
|
...registry.defaultOptions,
|
|
23
22
|
...OPTIONS.create,
|
|
@@ -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) await 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
|
};
|
package/dist/esm/update.js
CHANGED
|
@@ -42,37 +42,28 @@ const update = async function(params = {}, opts) {
|
|
|
42
42
|
const { parent, node, key } = element;
|
|
43
43
|
const { excludes, preventInheritAtCurrentState } = options;
|
|
44
44
|
let ref = element.__ref;
|
|
45
|
-
if (!ref)
|
|
46
|
-
ref = element.__ref = {};
|
|
45
|
+
if (!ref) ref = element.__ref = {};
|
|
47
46
|
const [snapshotOnCallee, calleeElement, snapshotHasUpdated] = captureSnapshot(element, options);
|
|
48
|
-
if (snapshotHasUpdated)
|
|
49
|
-
|
|
50
|
-
if (
|
|
51
|
-
|
|
52
|
-
if (preventInheritAtCurrentState && preventInheritAtCurrentState.__element === element)
|
|
53
|
-
return;
|
|
54
|
-
if (!excludes)
|
|
55
|
-
merge(options, UPDATE_DEFAULT_OPTIONS);
|
|
47
|
+
if (snapshotHasUpdated) return;
|
|
48
|
+
if (!options.preventListeners) await triggerEventOnUpdate("startUpdate", params, element, options);
|
|
49
|
+
if (preventInheritAtCurrentState && preventInheritAtCurrentState.__element === element) return;
|
|
50
|
+
if (!excludes) merge(options, UPDATE_DEFAULT_OPTIONS);
|
|
56
51
|
if (isString(params) || isNumber(params)) {
|
|
57
52
|
params = { text: params };
|
|
58
53
|
}
|
|
59
54
|
const inheritState = await inheritStateUpdates(element, options);
|
|
60
|
-
if (inheritState === false)
|
|
61
|
-
return;
|
|
55
|
+
if (inheritState === false) return;
|
|
62
56
|
const ifFails = checkIfOnUpdate(element, parent, options);
|
|
63
|
-
if (ifFails)
|
|
64
|
-
return;
|
|
57
|
+
if (ifFails) return;
|
|
65
58
|
if (ref.__if && !options.preventPropsUpdate) {
|
|
66
59
|
const hasParentProps = parent.props && (parent.props[key] || parent.props.childProps);
|
|
67
60
|
const hasFunctionInProps = ref.__props.filter((v) => isFunction(v));
|
|
68
61
|
const props = params.props || hasParentProps || hasFunctionInProps.length;
|
|
69
|
-
if (props)
|
|
70
|
-
updateProps(props, element, parent);
|
|
62
|
+
if (props) updateProps(props, element, parent);
|
|
71
63
|
}
|
|
72
64
|
if (!options.preventBeforeUpdateListener && !options.preventListeners) {
|
|
73
65
|
const beforeUpdateReturns = await triggerEventOnUpdate("beforeUpdate", params, element, options);
|
|
74
|
-
if (beforeUpdateReturns === false)
|
|
75
|
-
return element;
|
|
66
|
+
if (beforeUpdateReturns === false) return element;
|
|
76
67
|
}
|
|
77
68
|
overwriteDeep(element, params, { exclude: METHODS_EXL });
|
|
78
69
|
throughExecProps(element);
|
|
@@ -81,8 +72,7 @@ const update = async function(params = {}, opts) {
|
|
|
81
72
|
if (!options.isForced && !options.preventListeners) {
|
|
82
73
|
triggerEventOn("beforeClassAssign", element, options);
|
|
83
74
|
}
|
|
84
|
-
if (!ref.__if)
|
|
85
|
-
return false;
|
|
75
|
+
if (!ref.__if) return false;
|
|
86
76
|
if (!node) {
|
|
87
77
|
return;
|
|
88
78
|
}
|
|
@@ -97,49 +87,41 @@ const update = async function(params = {}, opts) {
|
|
|
97
87
|
preventUpdateAfterCount
|
|
98
88
|
} = options;
|
|
99
89
|
if (preventUpdateAfter) {
|
|
100
|
-
if (isNumber(preventUpdateAfterCount) && preventUpdateAfter <= preventUpdateAfterCount)
|
|
101
|
-
|
|
102
|
-
else
|
|
103
|
-
options.preventUpdateAfterCount = 1;
|
|
104
|
-
else
|
|
105
|
-
options.preventUpdateAfterCount++;
|
|
90
|
+
if (isNumber(preventUpdateAfterCount) && preventUpdateAfter <= preventUpdateAfterCount) return;
|
|
91
|
+
else if (options.preventUpdateAfterCount === void 0) options.preventUpdateAfterCount = 1;
|
|
92
|
+
else options.preventUpdateAfterCount++;
|
|
106
93
|
}
|
|
107
94
|
for (const param in element) {
|
|
108
95
|
const prop = element[param];
|
|
109
|
-
if (!Object.hasOwnProperty.call(element, param))
|
|
110
|
-
continue;
|
|
96
|
+
if (!Object.hasOwnProperty.call(element, param)) continue;
|
|
111
97
|
const isInPreventUpdate = isArray(preventUpdate) && preventUpdate.includes(param);
|
|
112
98
|
const isInPreventDefineUpdate = isArray(preventDefineUpdate) && preventDefineUpdate.includes(param);
|
|
113
99
|
const hasCollection = element.$collection || element.$stateCollection || element.$propsCollection;
|
|
114
|
-
if (isUndefined(prop) || isInPreventUpdate || isInPreventDefineUpdate || preventDefineUpdate === true || preventDefineUpdate === param || preventContentUpdate && param === "content" && !hasCollection || (preventStateUpdate && param) === "state" || isMethod(param, element) || isObject(REGISTRY[param]) || isVariant(param))
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
options.preventStateUpdate = false;
|
|
118
|
-
const isElement = applyParam(param, element, options);
|
|
100
|
+
if (isUndefined(prop) || isInPreventUpdate || isInPreventDefineUpdate || preventDefineUpdate === true || preventDefineUpdate === param || preventContentUpdate && param === "content" && !hasCollection || (preventStateUpdate && param) === "state" || isMethod(param, element) || isObject(REGISTRY[param]) || isVariant(param)) continue;
|
|
101
|
+
if (preventStateUpdate === "once") options.preventStateUpdate = false;
|
|
102
|
+
const isElement = await applyParam(param, element, options);
|
|
119
103
|
if (isElement) {
|
|
120
104
|
const { hasDefine, hasContextDefine } = isElement;
|
|
121
105
|
const canUpdate = isObject(prop) && !hasDefine && !hasContextDefine && !preventRecursive;
|
|
122
|
-
if (!canUpdate)
|
|
123
|
-
continue;
|
|
106
|
+
if (!canUpdate) continue;
|
|
124
107
|
const lazyLoad = element.props.lazyLoad || options.lazyLoad;
|
|
125
108
|
if (options.onEachUpdate) {
|
|
126
109
|
options.onEachUpdate(param, element, element.state, element.context);
|
|
127
110
|
}
|
|
128
|
-
const childUpdateCall = () => update.call(prop, params[prop], {
|
|
111
|
+
const childUpdateCall = async () => await update.call(prop, params[prop], {
|
|
129
112
|
...options,
|
|
130
113
|
currentSnapshot: snapshotOnCallee,
|
|
131
114
|
calleeElement
|
|
132
115
|
});
|
|
133
|
-
lazyLoad ? window.requestAnimationFrame(() => {
|
|
134
|
-
childUpdateCall();
|
|
116
|
+
lazyLoad ? window.requestAnimationFrame(async () => {
|
|
117
|
+
await childUpdateCall();
|
|
135
118
|
if (!options.preventUpdateListener) {
|
|
136
119
|
triggerEventOn("lazyLoad", element, options);
|
|
137
120
|
}
|
|
138
|
-
}) : childUpdateCall();
|
|
121
|
+
}) : await childUpdateCall();
|
|
139
122
|
}
|
|
140
123
|
}
|
|
141
|
-
if (!preventUpdateListener)
|
|
142
|
-
triggerEventOn("update", element, options);
|
|
124
|
+
if (!preventUpdateListener) await triggerEventOn("update", element, options);
|
|
143
125
|
};
|
|
144
126
|
const captureSnapshot = (element, options) => {
|
|
145
127
|
const ref = element.__ref;
|
|
@@ -158,8 +140,7 @@ const captureSnapshot = (element, options) => {
|
|
|
158
140
|
};
|
|
159
141
|
const checkIfOnUpdate = (element, parent, options) => {
|
|
160
142
|
var _a, _b, _c;
|
|
161
|
-
if (!isFunction(element.if) && !isFunction((_a = element.props) == null ? void 0 : _a.if) || !parent)
|
|
162
|
-
return;
|
|
143
|
+
if (!isFunction(element.if) && !isFunction((_a = element.props) == null ? void 0 : _a.if) || !parent) return;
|
|
163
144
|
const ref = element.__ref;
|
|
164
145
|
const ifPassed = (element.if || ((_b = element.props) == null ? void 0 : _b.if))(element, element.state, element.context, options);
|
|
165
146
|
const itWasFalse = ref.__if !== true;
|
|
@@ -184,8 +165,7 @@ const checkIfOnUpdate = (element, parent, options) => {
|
|
|
184
165
|
const contentKey = ref.contentElementKey;
|
|
185
166
|
if (element.$collection || element.$stateCollection || element.$propsCollection) {
|
|
186
167
|
element.removeContent();
|
|
187
|
-
} else if ((_c = element[contentKey]) == null ? void 0 : _c.parseDeep)
|
|
188
|
-
element[contentKey] = element[contentKey].parseDeep();
|
|
168
|
+
} else if ((_c = element[contentKey]) == null ? void 0 : _c.parseDeep) element[contentKey] = element[contentKey].parseDeep();
|
|
189
169
|
const previousElement = element.previousElement();
|
|
190
170
|
const previousNode = previousElement == null ? void 0 : previousElement.node;
|
|
191
171
|
const hasPrevious = previousNode == null ? void 0 : previousNode.parentNode;
|
|
@@ -214,8 +194,7 @@ const inheritStateUpdates = async (element, options) => {
|
|
|
214
194
|
const stateKey = ref.__state;
|
|
215
195
|
const { parent, state } = element;
|
|
216
196
|
const { preventUpdateTriggerStateUpdate, isHoisted, execStateFunction } = options;
|
|
217
|
-
if (preventUpdateTriggerStateUpdate)
|
|
218
|
-
return;
|
|
197
|
+
if (preventUpdateTriggerStateUpdate) return;
|
|
219
198
|
if (!stateKey && !ref.__hasRootState) {
|
|
220
199
|
element.state = parent && parent.state || {};
|
|
221
200
|
return;
|
|
@@ -227,25 +206,22 @@ const inheritStateUpdates = async (element, options) => {
|
|
|
227
206
|
return;
|
|
228
207
|
}
|
|
229
208
|
const keyInParentState = findInheritedState(element, element.parent);
|
|
230
|
-
if (!keyInParentState || options.preventInheritedStateUpdate)
|
|
231
|
-
return;
|
|
209
|
+
if (!keyInParentState || options.preventInheritedStateUpdate) return;
|
|
232
210
|
if (!options.preventBeforeStateUpdateListener && !options.preventListeners) {
|
|
233
211
|
const initStateReturns = await triggerEventOnUpdate("beforeStateUpdate", keyInParentState, element, options);
|
|
234
|
-
if (initStateReturns === false)
|
|
235
|
-
return element;
|
|
212
|
+
if (initStateReturns === false) return element;
|
|
236
213
|
}
|
|
237
|
-
const newState = createStateUpdate(element, parent, options);
|
|
214
|
+
const newState = await createStateUpdate(element, parent, options);
|
|
238
215
|
if (!options.preventStateUpdateListener && !options.preventListeners) {
|
|
239
216
|
await triggerEventOnUpdate("stateUpdate", newState.parse(), element, options);
|
|
240
217
|
}
|
|
241
218
|
};
|
|
242
|
-
const createStateUpdate = (element, parent, options) => {
|
|
219
|
+
const createStateUpdate = async (element, parent, options) => {
|
|
243
220
|
const __stateChildren = element.state.__children;
|
|
244
|
-
const newState = createState(element, parent);
|
|
221
|
+
const newState = await createState(element, parent);
|
|
245
222
|
element.state = newState;
|
|
246
223
|
for (const child in __stateChildren) {
|
|
247
|
-
if (newState[child])
|
|
248
|
-
newState.__children[child] = __stateChildren[child];
|
|
224
|
+
if (newState[child]) newState.__children[child] = __stateChildren[child];
|
|
249
225
|
Object.getPrototypeOf(__stateChildren[child]).parent = newState;
|
|
250
226
|
}
|
|
251
227
|
return newState;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isFunction } from "@domql/utils";
|
|
2
2
|
import { REGISTRY } from "../mixins/index.js";
|
|
3
|
-
const applyParam = (param, element, options) => {
|
|
3
|
+
const applyParam = async (param, element, options) => {
|
|
4
4
|
const { node, context, __ref: ref } = element;
|
|
5
5
|
const prop = element[param];
|
|
6
6
|
const { onlyUpdate } = options;
|
|
@@ -9,12 +9,11 @@ const applyParam = (param, element, options) => {
|
|
|
9
9
|
const isGlobalTransformer = DOMQLPropertyFromContext || DOMQLProperty;
|
|
10
10
|
const hasDefine = element.define && element.define[param];
|
|
11
11
|
const hasContextDefine = context && context.define && context.define[param];
|
|
12
|
-
if (!ref.__if)
|
|
13
|
-
return;
|
|
12
|
+
if (!ref.__if) return;
|
|
14
13
|
const hasOnlyUpdate = onlyUpdate ? onlyUpdate === param || element.lookup(onlyUpdate) : true;
|
|
15
14
|
if (isGlobalTransformer && !hasContextDefine && hasOnlyUpdate) {
|
|
16
15
|
if (isFunction(isGlobalTransformer)) {
|
|
17
|
-
isGlobalTransformer(prop, element, node, options);
|
|
16
|
+
await isGlobalTransformer(prop, element, node, options);
|
|
18
17
|
return;
|
|
19
18
|
}
|
|
20
19
|
}
|
|
@@ -29,8 +29,7 @@ const createValidDomqlObjectFromSugar = (el, parent, key, options) => {
|
|
|
29
29
|
};
|
|
30
30
|
const overwriteVariant = (element, variant, variantProps) => {
|
|
31
31
|
let variantElement = element[variant];
|
|
32
|
-
if (!variantElement)
|
|
33
|
-
return;
|
|
32
|
+
if (!variantElement) return;
|
|
34
33
|
const props = isObject(variantProps) ? variantProps : {};
|
|
35
34
|
if (isString(variantElement)) {
|
|
36
35
|
variantElement = {
|
|
@@ -45,16 +44,14 @@ const overwriteVariant = (element, variant, variantProps) => {
|
|
|
45
44
|
};
|
|
46
45
|
const applyVariant = (element) => {
|
|
47
46
|
const { props } = element;
|
|
48
|
-
if (!hasVariantProp(element))
|
|
49
|
-
return element;
|
|
47
|
+
if (!hasVariantProp(element)) return element;
|
|
50
48
|
const { variant } = props;
|
|
51
49
|
overwriteVariant(element, `.${variant}`);
|
|
52
50
|
const elKeys = Object.keys(element).filter((key) => isVariant(key));
|
|
53
51
|
elKeys.forEach((variant2) => {
|
|
54
52
|
const slicedVariantElementKey = variant2.slice(1);
|
|
55
53
|
const variantElementProps = props[slicedVariantElementKey];
|
|
56
|
-
if (variantElementProps)
|
|
57
|
-
overwriteVariant(element, variant2, variantElementProps);
|
|
54
|
+
if (variantElementProps) overwriteVariant(element, variant2, variantElementProps);
|
|
58
55
|
});
|
|
59
56
|
return element;
|
|
60
57
|
};
|
|
@@ -32,21 +32,16 @@ const deepExtend = (extend, stack, context) => {
|
|
|
32
32
|
return stack;
|
|
33
33
|
};
|
|
34
34
|
const flattenExtend = (extend, stack, context) => {
|
|
35
|
-
if (!extend)
|
|
36
|
-
|
|
37
|
-
if (
|
|
38
|
-
return extractArrayExtend(extend, stack, context);
|
|
39
|
-
if (isString(extend))
|
|
40
|
-
extend = fallbackStringExtend(extend, context);
|
|
35
|
+
if (!extend) return stack;
|
|
36
|
+
if (isArray(extend)) return extractArrayExtend(extend, stack, context);
|
|
37
|
+
if (isString(extend)) extend = fallbackStringExtend(extend, context);
|
|
41
38
|
stack.push(extend);
|
|
42
|
-
if (extend.extend)
|
|
43
|
-
deepExtend(extend, stack, context);
|
|
39
|
+
if (extend.extend) deepExtend(extend, stack, context);
|
|
44
40
|
return stack;
|
|
45
41
|
};
|
|
46
42
|
const deepMergeExtend = (element, extend) => {
|
|
47
43
|
for (const e in extend) {
|
|
48
|
-
if (["parent", "node", "__element"].indexOf(e) > -1)
|
|
49
|
-
continue;
|
|
44
|
+
if (["parent", "node", "__element"].indexOf(e) > -1) continue;
|
|
50
45
|
const elementProp = element[e];
|
|
51
46
|
const extendProp = extend[e];
|
|
52
47
|
if (elementProp === void 0) {
|
|
@@ -75,10 +70,8 @@ const fallbackStringExtend = (extend, context, options = {}, variant) => {
|
|
|
75
70
|
if (isString(extend)) {
|
|
76
71
|
const componentExists = COMPONENTS && (COMPONENTS[extend + "." + variant] || COMPONENTS[extend] || COMPONENTS["smbls." + extend]);
|
|
77
72
|
const pageExists = PAGES && extend.startsWith("/") && PAGES[extend];
|
|
78
|
-
if (componentExists)
|
|
79
|
-
|
|
80
|
-
else if (pageExists)
|
|
81
|
-
return pageExists;
|
|
73
|
+
if (componentExists) return componentExists;
|
|
74
|
+
else if (pageExists) return pageExists;
|
|
82
75
|
else {
|
|
83
76
|
if (options.verbose && (ENV === "testing" || ENV === "development")) {
|
|
84
77
|
console.warn("Extend is string but component was not found:", extend);
|
|
@@ -92,10 +85,8 @@ const jointStacks = (extendStack, childExtendStack) => {
|
|
|
92
85
|
return [].concat(extendStack.slice(0, 1)).concat(childExtendStack.slice(0, 1)).concat(extendStack.slice(1)).concat(childExtendStack.slice(1));
|
|
93
86
|
};
|
|
94
87
|
const getExtendStack = (extend, context) => {
|
|
95
|
-
if (!extend)
|
|
96
|
-
|
|
97
|
-
if (extend.__hash)
|
|
98
|
-
return getHashedExtend(extend) || [];
|
|
88
|
+
if (!extend) return [];
|
|
89
|
+
if (extend.__hash) return getHashedExtend(extend) || [];
|
|
99
90
|
const stack = flattenExtend(extend, [], context);
|
|
100
91
|
return getExtendStackRegistry(extend, stack);
|
|
101
92
|
};
|
package/dist/esm/utils/object.js
CHANGED
|
@@ -63,8 +63,7 @@ const METHODS_EXL = joinArrays(
|
|
|
63
63
|
);
|
|
64
64
|
const deepMerge = (element, extend, exclude = METHODS_EXL) => {
|
|
65
65
|
for (const e in extend) {
|
|
66
|
-
if (exclude.includes(e))
|
|
67
|
-
continue;
|
|
66
|
+
if (exclude.includes(e)) continue;
|
|
68
67
|
const elementProp = element[e];
|
|
69
68
|
const extendProp = extend[e];
|
|
70
69
|
if (elementProp === void 0) {
|
|
@@ -78,8 +77,7 @@ const deepMerge = (element, extend, exclude = METHODS_EXL) => {
|
|
|
78
77
|
const clone = (obj, exclude = METHODS_EXL) => {
|
|
79
78
|
const o = {};
|
|
80
79
|
for (const e in obj) {
|
|
81
|
-
if (exclude.includes(e))
|
|
82
|
-
continue;
|
|
80
|
+
if (exclude.includes(e)) continue;
|
|
83
81
|
o[e] = obj[e];
|
|
84
82
|
}
|
|
85
83
|
return o;
|
|
@@ -89,31 +87,27 @@ const overwrite = (element, params, options) => {
|
|
|
89
87
|
const { __ref } = element;
|
|
90
88
|
const { __exec, __cached } = __ref;
|
|
91
89
|
for (const e in params) {
|
|
92
|
-
if (e === "props" || e === "state" || e === "__ref")
|
|
93
|
-
continue;
|
|
90
|
+
if (e === "props" || e === "state" || e === "__ref") continue;
|
|
94
91
|
const elementProp = element[e];
|
|
95
92
|
const paramsProp = params[e];
|
|
96
93
|
if (paramsProp !== void 0) {
|
|
97
94
|
__cached[e] = changes[e] = elementProp;
|
|
98
95
|
element[e] = paramsProp;
|
|
99
96
|
}
|
|
100
|
-
if (options.cleanExec)
|
|
101
|
-
delete __exec[e];
|
|
97
|
+
if (options.cleanExec) delete __exec[e];
|
|
102
98
|
}
|
|
103
99
|
return changes;
|
|
104
100
|
};
|
|
105
101
|
const overwriteShallow = (obj, params, exclude = METHODS_EXL) => {
|
|
106
102
|
for (const e in params) {
|
|
107
|
-
if (exclude.includes(e))
|
|
108
|
-
continue;
|
|
103
|
+
if (exclude.includes(e)) continue;
|
|
109
104
|
obj[e] = params[e];
|
|
110
105
|
}
|
|
111
106
|
return obj;
|
|
112
107
|
};
|
|
113
108
|
const overwriteDeep = (obj, params, exclude = METHODS_EXL) => {
|
|
114
109
|
for (const e in params) {
|
|
115
|
-
if (exclude.includes(e))
|
|
116
|
-
continue;
|
|
110
|
+
if (exclude.includes(e)) continue;
|
|
117
111
|
const objProp = obj[e];
|
|
118
112
|
const paramsProp = params[e];
|
|
119
113
|
if (isObjectLike(objProp) && isObjectLike(paramsProp)) {
|
|
@@ -125,8 +119,7 @@ const overwriteDeep = (obj, params, exclude = METHODS_EXL) => {
|
|
|
125
119
|
return obj;
|
|
126
120
|
};
|
|
127
121
|
const mergeIfExisted = (a, b) => {
|
|
128
|
-
if (isObjectLike(a) && isObjectLike(b))
|
|
129
|
-
return deepMerge(a, b);
|
|
122
|
+
if (isObjectLike(a) && isObjectLike(b)) return deepMerge(a, b);
|
|
130
123
|
return a || b;
|
|
131
124
|
};
|
|
132
125
|
const mergeArray = (arr, exclude = ["parent", "node", "__element", "state", "context", "__ref"]) => {
|
|
@@ -139,8 +132,7 @@ const flattenRecursive = (param, prop, stack = []) => {
|
|
|
139
132
|
const objectized = mergeAndCloneIfArray(param);
|
|
140
133
|
stack.push(objectized);
|
|
141
134
|
const extendOfExtend = objectized[prop];
|
|
142
|
-
if (extendOfExtend)
|
|
143
|
-
flattenRecursive(extendOfExtend, prop, stack);
|
|
135
|
+
if (extendOfExtend) flattenRecursive(extendOfExtend, prop, stack);
|
|
144
136
|
delete objectized[prop];
|
|
145
137
|
return stack;
|
|
146
138
|
};
|
|
@@ -13,24 +13,15 @@ const onlyResolveExtends = (element, parent, key, options) => {
|
|
|
13
13
|
element.tag = detectTag(element);
|
|
14
14
|
{
|
|
15
15
|
const { __ref: ref2 } = element;
|
|
16
|
-
if (!ref2.__cached)
|
|
17
|
-
|
|
18
|
-
if (!ref2.
|
|
19
|
-
|
|
20
|
-
if (!ref2.
|
|
21
|
-
|
|
22
|
-
if (!ref2.
|
|
23
|
-
|
|
24
|
-
if (!ref2.
|
|
25
|
-
ref2.__class = {};
|
|
26
|
-
if (!ref2.__classNames)
|
|
27
|
-
ref2.__classNames = {};
|
|
28
|
-
if (!ref2.__attr)
|
|
29
|
-
ref2.__attr = {};
|
|
30
|
-
if (!ref2.__changes)
|
|
31
|
-
ref2.__changes = [];
|
|
32
|
-
if (!ref2.__children)
|
|
33
|
-
ref2.__children = [];
|
|
16
|
+
if (!ref2.__cached) ref2.__cached = {};
|
|
17
|
+
if (!ref2.__defineCache) ref2.__defineCache = {};
|
|
18
|
+
if (!ref2.__exec) ref2.__exec = {};
|
|
19
|
+
if (!ref2.__execProps) ref2.__execProps = {};
|
|
20
|
+
if (!ref2.__class) ref2.__class = {};
|
|
21
|
+
if (!ref2.__classNames) ref2.__classNames = {};
|
|
22
|
+
if (!ref2.__attr) ref2.__attr = {};
|
|
23
|
+
if (!ref2.__changes) ref2.__changes = [];
|
|
24
|
+
if (!ref2.__children) ref2.__children = [];
|
|
34
25
|
}
|
|
35
26
|
addMethods(element, parent, options);
|
|
36
27
|
createState(element, parent);
|
|
@@ -39,10 +30,8 @@ const onlyResolveExtends = (element, parent, key, options) => {
|
|
|
39
30
|
const ifPassed = element.if(element, element.state, element.context);
|
|
40
31
|
if (!ifPassed) {
|
|
41
32
|
delete ref.__if;
|
|
42
|
-
} else
|
|
43
|
-
|
|
44
|
-
} else
|
|
45
|
-
ref.__if = true;
|
|
33
|
+
} else ref.__if = true;
|
|
34
|
+
} else ref.__if = true;
|
|
46
35
|
if (element.node && ref.__if) {
|
|
47
36
|
parent[key || element.key] = element;
|
|
48
37
|
}
|
|
@@ -53,8 +42,7 @@ const onlyResolveExtends = (element, parent, key, options) => {
|
|
|
53
42
|
throughInitialExec(element);
|
|
54
43
|
for (const param in element) {
|
|
55
44
|
const prop = element[param];
|
|
56
|
-
if (isUndefined(prop) || isMethod(param, element) || isObject(REGISTRY[param]) || isVariant(param))
|
|
57
|
-
continue;
|
|
45
|
+
if (isUndefined(prop) || isMethod(param, element) || isObject(REGISTRY[param]) || isVariant(param)) continue;
|
|
58
46
|
const hasDefine = element.define && element.define[param];
|
|
59
47
|
const contextHasDefine = element.context && element.context.define && element.context.define[param];
|
|
60
48
|
const optionsHasDefine = options.define && options.define[param];
|
|
@@ -72,8 +60,7 @@ const onlyResolveExtends = (element, parent, key, options) => {
|
|
|
72
60
|
delete element.props.update;
|
|
73
61
|
delete element.props.__element;
|
|
74
62
|
}
|
|
75
|
-
if (!options.keepRef)
|
|
76
|
-
delete element.__ref;
|
|
63
|
+
if (!options.keepRef) delete element.__ref;
|
|
77
64
|
return element;
|
|
78
65
|
};
|
|
79
66
|
export {
|
|
@@ -9,11 +9,9 @@ const propagateEventsFromProps = (element) => {
|
|
|
9
9
|
if (isFunction(origEvent)) {
|
|
10
10
|
on[eventName] = (...args) => {
|
|
11
11
|
const originalEventRetunrs = origEvent(...args);
|
|
12
|
-
if (originalEventRetunrs !== false)
|
|
13
|
-
funcFromProps(...args);
|
|
12
|
+
if (originalEventRetunrs !== false) funcFromProps(...args);
|
|
14
13
|
};
|
|
15
|
-
} else
|
|
16
|
-
on[eventName] = funcFromProps;
|
|
14
|
+
} else on[eventName] = funcFromProps;
|
|
17
15
|
});
|
|
18
16
|
};
|
|
19
17
|
export {
|
package/mixins/content.js
CHANGED
|
@@ -41,13 +41,13 @@ export const removeContent = function (el, opts = {}) {
|
|
|
41
41
|
* Appends anything as content
|
|
42
42
|
* an original one as a child
|
|
43
43
|
*/
|
|
44
|
-
export function setContent (param, element, node, opts) {
|
|
44
|
+
export async function setContent (param, element, node, opts) {
|
|
45
45
|
const contentElementKey = setContentKey(element, opts)
|
|
46
46
|
if (param && element) {
|
|
47
47
|
if (element[contentElementKey].update) {
|
|
48
48
|
element[contentElementKey].update({}, opts)
|
|
49
49
|
} else {
|
|
50
|
-
set.call(element, param, opts)
|
|
50
|
+
await set.call(element, param, opts)
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
}
|
package/node.js
CHANGED
|
@@ -34,7 +34,7 @@ export const createNode = async (element, options) => {
|
|
|
34
34
|
} else node = element.node = cacheNode(element)
|
|
35
35
|
|
|
36
36
|
// trigger `on.attachNode`
|
|
37
|
-
triggerEventOn('attachNode', element, options)
|
|
37
|
+
await triggerEventOn('attachNode', element, options)
|
|
38
38
|
}
|
|
39
39
|
// node.dataset // .key = element.key
|
|
40
40
|
|
|
@@ -72,7 +72,7 @@ export const createNode = async (element, options) => {
|
|
|
72
72
|
isObject(REGISTRY[param])
|
|
73
73
|
) continue
|
|
74
74
|
|
|
75
|
-
const isElement = applyParam(param, element, options)
|
|
75
|
+
const isElement = await applyParam(param, element, options)
|
|
76
76
|
if (isElement) {
|
|
77
77
|
const { hasDefine, hasContextDefine } = isElement
|
|
78
78
|
if (element[param] && !hasDefine && !hasContextDefine) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@domql/element",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.206",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "index.js",
|
|
@@ -29,10 +29,10 @@
|
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@domql/event": "^2.5.203",
|
|
31
31
|
"@domql/render": "^2.5.203",
|
|
32
|
-
"@domql/state": "^2.5.
|
|
32
|
+
"@domql/state": "^2.5.206",
|
|
33
33
|
"@domql/utils": "^2.5.203"
|
|
34
34
|
},
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "8d50915b5d72df7c8bdf35096b0a9cf50dc4d22e",
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@babel/core": "^7.12.0"
|
|
38
38
|
}
|
package/set.js
CHANGED
|
@@ -19,9 +19,9 @@ export const resetElement = async (params, element, options) => {
|
|
|
19
19
|
})
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
export const reset = (options) => {
|
|
22
|
+
export const reset = async (options) => {
|
|
23
23
|
const element = this
|
|
24
|
-
create(element, element.parent, undefined, {
|
|
24
|
+
await create(element, element.parent, undefined, {
|
|
25
25
|
ignoreChildExtend: true,
|
|
26
26
|
...registry.defaultOptions,
|
|
27
27
|
...OPTIONS.create,
|
|
@@ -45,7 +45,7 @@ export const set = async function (params, options = {}, el) {
|
|
|
45
45
|
const beforeUpdateReturns = await triggerEventOnUpdate('beforeUpdate', params, element, options)
|
|
46
46
|
if (beforeUpdateReturns === false) return element
|
|
47
47
|
}
|
|
48
|
-
if (content?.update) content.update()
|
|
48
|
+
if (content?.update) await content.update()
|
|
49
49
|
if (!options.preventUpdateListener) await triggerEventOn('update', element, options)
|
|
50
50
|
return
|
|
51
51
|
}
|
package/update.js
CHANGED
|
@@ -133,7 +133,7 @@ export const update = async function (params = {}, opts) {
|
|
|
133
133
|
|
|
134
134
|
if (preventStateUpdate === 'once') options.preventStateUpdate = false
|
|
135
135
|
|
|
136
|
-
const isElement = applyParam(param, element, options)
|
|
136
|
+
const isElement = await applyParam(param, element, options)
|
|
137
137
|
if (isElement) {
|
|
138
138
|
const { hasDefine, hasContextDefine } = isElement
|
|
139
139
|
const canUpdate = isObject(prop) && !hasDefine && !hasContextDefine && !preventRecursive
|
|
@@ -145,23 +145,23 @@ export const update = async function (params = {}, opts) {
|
|
|
145
145
|
options.onEachUpdate(param, element, element.state, element.context)
|
|
146
146
|
}
|
|
147
147
|
|
|
148
|
-
const childUpdateCall = () => update.call(prop, params[prop], {
|
|
148
|
+
const childUpdateCall = async () => await update.call(prop, params[prop], {
|
|
149
149
|
...options,
|
|
150
150
|
currentSnapshot: snapshotOnCallee,
|
|
151
151
|
calleeElement
|
|
152
152
|
})
|
|
153
153
|
|
|
154
|
-
lazyLoad ? window.requestAnimationFrame(() => { // eslint-disable-line
|
|
155
|
-
childUpdateCall()
|
|
154
|
+
lazyLoad ? window.requestAnimationFrame(async () => { // eslint-disable-line
|
|
155
|
+
await childUpdateCall()
|
|
156
156
|
// handle lazy load
|
|
157
157
|
if (!options.preventUpdateListener) {
|
|
158
158
|
triggerEventOn('lazyLoad', element, options)
|
|
159
159
|
}
|
|
160
|
-
}) : childUpdateCall()
|
|
160
|
+
}) : await childUpdateCall()
|
|
161
161
|
}
|
|
162
162
|
}
|
|
163
163
|
|
|
164
|
-
if (!preventUpdateListener) triggerEventOn('update', element, options)
|
|
164
|
+
if (!preventUpdateListener) await triggerEventOn('update', element, options)
|
|
165
165
|
}
|
|
166
166
|
|
|
167
167
|
const captureSnapshot = (element, options) => {
|
|
@@ -294,7 +294,7 @@ const inheritStateUpdates = async (element, options) => {
|
|
|
294
294
|
}
|
|
295
295
|
|
|
296
296
|
// Recreate the state again
|
|
297
|
-
const newState = createStateUpdate(element, parent, options)
|
|
297
|
+
const newState = await createStateUpdate(element, parent, options)
|
|
298
298
|
|
|
299
299
|
// Trigger on.stateUpdate event
|
|
300
300
|
if (!options.preventStateUpdateListener && !options.preventListeners) {
|
|
@@ -302,9 +302,9 @@ const inheritStateUpdates = async (element, options) => {
|
|
|
302
302
|
}
|
|
303
303
|
}
|
|
304
304
|
|
|
305
|
-
const createStateUpdate = (element, parent, options) => {
|
|
305
|
+
const createStateUpdate = async (element, parent, options) => {
|
|
306
306
|
const __stateChildren = element.state.__children
|
|
307
|
-
const newState = createState(element, parent)
|
|
307
|
+
const newState = await createState(element, parent)
|
|
308
308
|
element.state = newState
|
|
309
309
|
for (const child in __stateChildren) {
|
|
310
310
|
// check this for inherited states
|
package/utils/applyParam.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { isFunction } from '@domql/utils'
|
|
4
4
|
import { REGISTRY } from '../mixins/index.js'
|
|
5
5
|
|
|
6
|
-
export const applyParam = (param, element, options) => {
|
|
6
|
+
export const applyParam = async (param, element, options) => {
|
|
7
7
|
const { node, context, __ref: ref } = element
|
|
8
8
|
const prop = element[param]
|
|
9
9
|
|
|
@@ -22,7 +22,7 @@ export const applyParam = (param, element, options) => {
|
|
|
22
22
|
|
|
23
23
|
if (isGlobalTransformer && !hasContextDefine && hasOnlyUpdate) {
|
|
24
24
|
if (isFunction(isGlobalTransformer)) {
|
|
25
|
-
isGlobalTransformer(prop, element, node, options)
|
|
25
|
+
await isGlobalTransformer(prop, element, node, options)
|
|
26
26
|
return
|
|
27
27
|
}
|
|
28
28
|
}
|