@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
package/dist/cjs/set.js
CHANGED
|
@@ -31,7 +31,8 @@ var import_mixins = require("./mixins/index.js");
|
|
|
31
31
|
var import_content = require("./mixins/content.js");
|
|
32
32
|
var import_event = require("@domql/event");
|
|
33
33
|
const resetElement = async (params, element, options) => {
|
|
34
|
-
if (!options.preventRemove)
|
|
34
|
+
if (!options.preventRemove)
|
|
35
|
+
(0, import_content.removeContent)(element, options);
|
|
35
36
|
const { __ref: ref } = element;
|
|
36
37
|
await (0, import_create.create)(params, element, ref.contentElementKey || "content", {
|
|
37
38
|
ignoreChildExtend: true,
|
|
@@ -57,19 +58,24 @@ const set = async function(params, options = {}, el) {
|
|
|
57
58
|
const __contentRef = content && content.__ref;
|
|
58
59
|
const lazyLoad = element.props && element.props.lazyLoad;
|
|
59
60
|
const hasCollection = element.$collection || element.$stateCollection || element.$propsCollection;
|
|
60
|
-
if (options.preventContentUpdate === true && !hasCollection)
|
|
61
|
+
if (options.preventContentUpdate === true && !hasCollection)
|
|
62
|
+
return;
|
|
61
63
|
if (ref.__noCollectionDifference || __contentRef && __contentRef.__cached && (0, import_utils.deepContains)(params, content)) {
|
|
62
64
|
if (!options.preventBeforeUpdateListener && !options.preventListeners) {
|
|
63
65
|
const beforeUpdateReturns = await (0, import_event.triggerEventOnUpdate)("beforeUpdate", params, element, options);
|
|
64
|
-
if (beforeUpdateReturns === false)
|
|
66
|
+
if (beforeUpdateReturns === false)
|
|
67
|
+
return element;
|
|
65
68
|
}
|
|
66
|
-
if (content == null ? void 0 : content.update)
|
|
67
|
-
|
|
69
|
+
if (content == null ? void 0 : content.update)
|
|
70
|
+
content.update();
|
|
71
|
+
if (!options.preventUpdateListener)
|
|
72
|
+
await (0, import_event.triggerEventOn)("update", element, options);
|
|
68
73
|
return;
|
|
69
74
|
}
|
|
70
75
|
if (params) {
|
|
71
76
|
let { childExtend, props } = params;
|
|
72
|
-
if (!props)
|
|
77
|
+
if (!props)
|
|
78
|
+
props = params.props = {};
|
|
73
79
|
if (!childExtend && element.childExtend) {
|
|
74
80
|
params.childExtend = element.childExtend;
|
|
75
81
|
props.ignoreChildExtend = true;
|
|
@@ -85,7 +91,8 @@ const set = async function(params, options = {}, el) {
|
|
|
85
91
|
(0, import_event.triggerEventOn)("lazyLoad", element, options);
|
|
86
92
|
}
|
|
87
93
|
});
|
|
88
|
-
} else
|
|
94
|
+
} else
|
|
95
|
+
await resetElement(params, element, options);
|
|
89
96
|
}
|
|
90
97
|
return element;
|
|
91
98
|
};
|
package/dist/cjs/update.js
CHANGED
|
@@ -52,28 +52,37 @@ const update = async function(params = {}, opts) {
|
|
|
52
52
|
const { parent, node, key } = element;
|
|
53
53
|
const { excludes, preventInheritAtCurrentState } = options;
|
|
54
54
|
let ref = element.__ref;
|
|
55
|
-
if (!ref)
|
|
55
|
+
if (!ref)
|
|
56
|
+
ref = element.__ref = {};
|
|
56
57
|
const [snapshotOnCallee, calleeElement, snapshotHasUpdated] = captureSnapshot(element, options);
|
|
57
|
-
if (snapshotHasUpdated)
|
|
58
|
-
|
|
59
|
-
if (
|
|
60
|
-
|
|
58
|
+
if (snapshotHasUpdated)
|
|
59
|
+
return;
|
|
60
|
+
if (!options.preventListeners)
|
|
61
|
+
await (0, import_event.triggerEventOnUpdate)("startUpdate", params, element, options);
|
|
62
|
+
if (preventInheritAtCurrentState && preventInheritAtCurrentState.__element === element)
|
|
63
|
+
return;
|
|
64
|
+
if (!excludes)
|
|
65
|
+
(0, import_utils.merge)(options, UPDATE_DEFAULT_OPTIONS);
|
|
61
66
|
if ((0, import_utils.isString)(params) || (0, import_utils.isNumber)(params)) {
|
|
62
67
|
params = { text: params };
|
|
63
68
|
}
|
|
64
69
|
const inheritState = await inheritStateUpdates(element, options);
|
|
65
|
-
if (inheritState === false)
|
|
70
|
+
if (inheritState === false)
|
|
71
|
+
return;
|
|
66
72
|
const ifFails = checkIfOnUpdate(element, parent, options);
|
|
67
|
-
if (ifFails)
|
|
73
|
+
if (ifFails)
|
|
74
|
+
return;
|
|
68
75
|
if (ref.__if && !options.preventPropsUpdate) {
|
|
69
76
|
const hasParentProps = parent.props && (parent.props[key] || parent.props.childProps);
|
|
70
77
|
const hasFunctionInProps = ref.__props.filter((v) => (0, import_utils.isFunction)(v));
|
|
71
78
|
const props = params.props || hasParentProps || hasFunctionInProps.length;
|
|
72
|
-
if (props)
|
|
79
|
+
if (props)
|
|
80
|
+
(0, import_props.updateProps)(props, element, parent);
|
|
73
81
|
}
|
|
74
82
|
if (!options.preventBeforeUpdateListener && !options.preventListeners) {
|
|
75
83
|
const beforeUpdateReturns = await (0, import_event.triggerEventOnUpdate)("beforeUpdate", params, element, options);
|
|
76
|
-
if (beforeUpdateReturns === false)
|
|
84
|
+
if (beforeUpdateReturns === false)
|
|
85
|
+
return element;
|
|
77
86
|
}
|
|
78
87
|
(0, import_utils.overwriteDeep)(element, params, { exclude: import_utils2.METHODS_EXL });
|
|
79
88
|
(0, import_iterate.throughExecProps)(element);
|
|
@@ -82,7 +91,8 @@ const update = async function(params = {}, opts) {
|
|
|
82
91
|
if (!options.isForced && !options.preventListeners) {
|
|
83
92
|
(0, import_event.triggerEventOn)("beforeClassAssign", element, options);
|
|
84
93
|
}
|
|
85
|
-
if (!ref.__if)
|
|
94
|
+
if (!ref.__if)
|
|
95
|
+
return false;
|
|
86
96
|
if (!node) {
|
|
87
97
|
return;
|
|
88
98
|
}
|
|
@@ -97,23 +107,30 @@ const update = async function(params = {}, opts) {
|
|
|
97
107
|
preventUpdateAfterCount
|
|
98
108
|
} = options;
|
|
99
109
|
if (preventUpdateAfter) {
|
|
100
|
-
if ((0, import_utils.isNumber)(preventUpdateAfterCount) && preventUpdateAfter <= preventUpdateAfterCount)
|
|
101
|
-
|
|
102
|
-
else options.preventUpdateAfterCount
|
|
110
|
+
if ((0, import_utils.isNumber)(preventUpdateAfterCount) && preventUpdateAfter <= preventUpdateAfterCount)
|
|
111
|
+
return;
|
|
112
|
+
else if (options.preventUpdateAfterCount === void 0)
|
|
113
|
+
options.preventUpdateAfterCount = 1;
|
|
114
|
+
else
|
|
115
|
+
options.preventUpdateAfterCount++;
|
|
103
116
|
}
|
|
104
117
|
for (const param in element) {
|
|
105
118
|
const prop = element[param];
|
|
106
|
-
if (!Object.hasOwnProperty.call(element, param))
|
|
119
|
+
if (!Object.hasOwnProperty.call(element, param))
|
|
120
|
+
continue;
|
|
107
121
|
const isInPreventUpdate = (0, import_utils.isArray)(preventUpdate) && preventUpdate.includes(param);
|
|
108
122
|
const isInPreventDefineUpdate = (0, import_utils.isArray)(preventDefineUpdate) && preventDefineUpdate.includes(param);
|
|
109
123
|
const hasCollection = element.$collection || element.$stateCollection || element.$propsCollection;
|
|
110
|
-
if ((0, import_utils.isUndefined)(prop) || isInPreventUpdate || isInPreventDefineUpdate || preventDefineUpdate === true || preventDefineUpdate === param || preventContentUpdate && param === "content" && !hasCollection || (preventStateUpdate && param) === "state" || (0, import_methods.isMethod)(param, element) || (0, import_utils.isObject)(import_mixins.REGISTRY[param]) || (0, import_utils.isVariant)(param))
|
|
111
|
-
|
|
124
|
+
if ((0, import_utils.isUndefined)(prop) || isInPreventUpdate || isInPreventDefineUpdate || preventDefineUpdate === true || preventDefineUpdate === param || preventContentUpdate && param === "content" && !hasCollection || (preventStateUpdate && param) === "state" || (0, import_methods.isMethod)(param, element) || (0, import_utils.isObject)(import_mixins.REGISTRY[param]) || (0, import_utils.isVariant)(param))
|
|
125
|
+
continue;
|
|
126
|
+
if (preventStateUpdate === "once")
|
|
127
|
+
options.preventStateUpdate = false;
|
|
112
128
|
const isElement = (0, import_applyParam.applyParam)(param, element, options);
|
|
113
129
|
if (isElement) {
|
|
114
130
|
const { hasDefine, hasContextDefine } = isElement;
|
|
115
131
|
const canUpdate = (0, import_utils.isObject)(prop) && !hasDefine && !hasContextDefine && !preventRecursive;
|
|
116
|
-
if (!canUpdate)
|
|
132
|
+
if (!canUpdate)
|
|
133
|
+
continue;
|
|
117
134
|
const lazyLoad = element.props.lazyLoad || options.lazyLoad;
|
|
118
135
|
if (options.onEachUpdate) {
|
|
119
136
|
options.onEachUpdate(param, element, element.state, element.context);
|
|
@@ -131,7 +148,8 @@ const update = async function(params = {}, opts) {
|
|
|
131
148
|
}) : childUpdateCall();
|
|
132
149
|
}
|
|
133
150
|
}
|
|
134
|
-
if (!preventUpdateListener)
|
|
151
|
+
if (!preventUpdateListener)
|
|
152
|
+
(0, import_event.triggerEventOn)("update", element, options);
|
|
135
153
|
};
|
|
136
154
|
const captureSnapshot = (element, options) => {
|
|
137
155
|
const ref = element.__ref;
|
|
@@ -150,7 +168,8 @@ const captureSnapshot = (element, options) => {
|
|
|
150
168
|
};
|
|
151
169
|
const checkIfOnUpdate = (element, parent, options) => {
|
|
152
170
|
var _a, _b, _c;
|
|
153
|
-
if (!(0, import_utils.isFunction)(element.if) && !(0, import_utils.isFunction)((_a = element.props) == null ? void 0 : _a.if) || !parent)
|
|
171
|
+
if (!(0, import_utils.isFunction)(element.if) && !(0, import_utils.isFunction)((_a = element.props) == null ? void 0 : _a.if) || !parent)
|
|
172
|
+
return;
|
|
154
173
|
const ref = element.__ref;
|
|
155
174
|
const ifPassed = (element.if || ((_b = element.props) == null ? void 0 : _b.if))(element, element.state, element.context, options);
|
|
156
175
|
const itWasFalse = ref.__if !== true;
|
|
@@ -175,7 +194,8 @@ const checkIfOnUpdate = (element, parent, options) => {
|
|
|
175
194
|
const contentKey = ref.contentElementKey;
|
|
176
195
|
if (element.$collection || element.$stateCollection || element.$propsCollection) {
|
|
177
196
|
element.removeContent();
|
|
178
|
-
} else if ((_c = element[contentKey]) == null ? void 0 : _c.parseDeep)
|
|
197
|
+
} else if ((_c = element[contentKey]) == null ? void 0 : _c.parseDeep)
|
|
198
|
+
element[contentKey] = element[contentKey].parseDeep();
|
|
179
199
|
const previousElement = element.previousElement();
|
|
180
200
|
const previousNode = previousElement == null ? void 0 : previousElement.node;
|
|
181
201
|
const hasPrevious = previousNode == null ? void 0 : previousNode.parentNode;
|
|
@@ -204,7 +224,8 @@ const inheritStateUpdates = async (element, options) => {
|
|
|
204
224
|
const stateKey = ref.__state;
|
|
205
225
|
const { parent, state } = element;
|
|
206
226
|
const { preventUpdateTriggerStateUpdate, isHoisted, execStateFunction } = options;
|
|
207
|
-
if (preventUpdateTriggerStateUpdate)
|
|
227
|
+
if (preventUpdateTriggerStateUpdate)
|
|
228
|
+
return;
|
|
208
229
|
if (!stateKey && !ref.__hasRootState) {
|
|
209
230
|
element.state = parent && parent.state || {};
|
|
210
231
|
return;
|
|
@@ -216,10 +237,12 @@ const inheritStateUpdates = async (element, options) => {
|
|
|
216
237
|
return;
|
|
217
238
|
}
|
|
218
239
|
const keyInParentState = (0, import_state.findInheritedState)(element, element.parent);
|
|
219
|
-
if (!keyInParentState || options.preventInheritedStateUpdate)
|
|
240
|
+
if (!keyInParentState || options.preventInheritedStateUpdate)
|
|
241
|
+
return;
|
|
220
242
|
if (!options.preventBeforeStateUpdateListener && !options.preventListeners) {
|
|
221
243
|
const initStateReturns = await (0, import_event.triggerEventOnUpdate)("beforeStateUpdate", keyInParentState, element, options);
|
|
222
|
-
if (initStateReturns === false)
|
|
244
|
+
if (initStateReturns === false)
|
|
245
|
+
return element;
|
|
223
246
|
}
|
|
224
247
|
const newState = createStateUpdate(element, parent, options);
|
|
225
248
|
if (!options.preventStateUpdateListener && !options.preventListeners) {
|
|
@@ -231,7 +254,8 @@ const createStateUpdate = (element, parent, options) => {
|
|
|
231
254
|
const newState = (0, import_state.createState)(element, parent);
|
|
232
255
|
element.state = newState;
|
|
233
256
|
for (const child in __stateChildren) {
|
|
234
|
-
if (newState[child])
|
|
257
|
+
if (newState[child])
|
|
258
|
+
newState.__children[child] = __stateChildren[child];
|
|
235
259
|
Object.getPrototypeOf(__stateChildren[child]).parent = newState;
|
|
236
260
|
}
|
|
237
261
|
return newState;
|
|
@@ -32,7 +32,8 @@ const applyParam = (param, element, options) => {
|
|
|
32
32
|
const isGlobalTransformer = DOMQLPropertyFromContext || DOMQLProperty;
|
|
33
33
|
const hasDefine = element.define && element.define[param];
|
|
34
34
|
const hasContextDefine = context && context.define && context.define[param];
|
|
35
|
-
if (!ref.__if)
|
|
35
|
+
if (!ref.__if)
|
|
36
|
+
return;
|
|
36
37
|
const hasOnlyUpdate = onlyUpdate ? onlyUpdate === param || element.lookup(onlyUpdate) : true;
|
|
37
38
|
if (isGlobalTransformer && !hasContextDefine && hasOnlyUpdate) {
|
|
38
39
|
if ((0, import_utils.isFunction)(isGlobalTransformer)) {
|
|
@@ -46,7 +46,8 @@ const createValidDomqlObjectFromSugar = (el, parent, key, options) => {
|
|
|
46
46
|
};
|
|
47
47
|
const overwriteVariant = (element, variant, variantProps) => {
|
|
48
48
|
let variantElement = element[variant];
|
|
49
|
-
if (!variantElement)
|
|
49
|
+
if (!variantElement)
|
|
50
|
+
return;
|
|
50
51
|
const props = (0, import_utils.isObject)(variantProps) ? variantProps : {};
|
|
51
52
|
if ((0, import_utils.isString)(variantElement)) {
|
|
52
53
|
variantElement = {
|
|
@@ -61,14 +62,16 @@ const overwriteVariant = (element, variant, variantProps) => {
|
|
|
61
62
|
};
|
|
62
63
|
const applyVariant = (element) => {
|
|
63
64
|
const { props } = element;
|
|
64
|
-
if (!(0, import_utils.hasVariantProp)(element))
|
|
65
|
+
if (!(0, import_utils.hasVariantProp)(element))
|
|
66
|
+
return element;
|
|
65
67
|
const { variant } = props;
|
|
66
68
|
overwriteVariant(element, `.${variant}`);
|
|
67
69
|
const elKeys = Object.keys(element).filter((key) => (0, import_utils.isVariant)(key));
|
|
68
70
|
elKeys.forEach((variant2) => {
|
|
69
71
|
const slicedVariantElementKey = variant2.slice(1);
|
|
70
72
|
const variantElementProps = props[slicedVariantElementKey];
|
|
71
|
-
if (variantElementProps)
|
|
73
|
+
if (variantElementProps)
|
|
74
|
+
overwriteVariant(element, variant2, variantElementProps);
|
|
72
75
|
});
|
|
73
76
|
return element;
|
|
74
77
|
};
|
|
@@ -69,16 +69,21 @@ const deepExtend = (extend, stack, context) => {
|
|
|
69
69
|
return stack;
|
|
70
70
|
};
|
|
71
71
|
const flattenExtend = (extend, stack, context) => {
|
|
72
|
-
if (!extend)
|
|
73
|
-
|
|
74
|
-
if ((0, import_utils.
|
|
72
|
+
if (!extend)
|
|
73
|
+
return stack;
|
|
74
|
+
if ((0, import_utils.isArray)(extend))
|
|
75
|
+
return extractArrayExtend(extend, stack, context);
|
|
76
|
+
if ((0, import_utils.isString)(extend))
|
|
77
|
+
extend = fallbackStringExtend(extend, context);
|
|
75
78
|
stack.push(extend);
|
|
76
|
-
if (extend.extend)
|
|
79
|
+
if (extend.extend)
|
|
80
|
+
deepExtend(extend, stack, context);
|
|
77
81
|
return stack;
|
|
78
82
|
};
|
|
79
83
|
const deepMergeExtend = (element, extend) => {
|
|
80
84
|
for (const e in extend) {
|
|
81
|
-
if (["parent", "node", "__element"].indexOf(e) > -1)
|
|
85
|
+
if (["parent", "node", "__element"].indexOf(e) > -1)
|
|
86
|
+
continue;
|
|
82
87
|
const elementProp = element[e];
|
|
83
88
|
const extendProp = extend[e];
|
|
84
89
|
if (elementProp === void 0) {
|
|
@@ -107,10 +112,12 @@ const fallbackStringExtend = (extend, context, options = {}, variant) => {
|
|
|
107
112
|
if ((0, import_utils.isString)(extend)) {
|
|
108
113
|
const componentExists = COMPONENTS && (COMPONENTS[extend + "." + variant] || COMPONENTS[extend] || COMPONENTS["smbls." + extend]);
|
|
109
114
|
const pageExists = PAGES && extend.startsWith("/") && PAGES[extend];
|
|
110
|
-
if (componentExists)
|
|
111
|
-
|
|
115
|
+
if (componentExists)
|
|
116
|
+
return componentExists;
|
|
117
|
+
else if (pageExists)
|
|
118
|
+
return pageExists;
|
|
112
119
|
else {
|
|
113
|
-
if (options.verbose && (ENV === "
|
|
120
|
+
if (options.verbose && (ENV === "testing" || ENV === "development")) {
|
|
114
121
|
console.warn("Extend is string but component was not found:", extend);
|
|
115
122
|
}
|
|
116
123
|
return {};
|
|
@@ -122,8 +129,10 @@ const jointStacks = (extendStack, childExtendStack) => {
|
|
|
122
129
|
return [].concat(extendStack.slice(0, 1)).concat(childExtendStack.slice(0, 1)).concat(extendStack.slice(1)).concat(childExtendStack.slice(1));
|
|
123
130
|
};
|
|
124
131
|
const getExtendStack = (extend, context) => {
|
|
125
|
-
if (!extend)
|
|
126
|
-
|
|
132
|
+
if (!extend)
|
|
133
|
+
return [];
|
|
134
|
+
if (extend.__hash)
|
|
135
|
+
return getHashedExtend(extend) || [];
|
|
127
136
|
const stack = flattenExtend(extend, [], context);
|
|
128
137
|
return getExtendStackRegistry(extend, stack);
|
|
129
138
|
};
|
package/dist/cjs/utils/object.js
CHANGED
|
@@ -96,7 +96,8 @@ const METHODS_EXL = (0, import_utils.joinArrays)(
|
|
|
96
96
|
);
|
|
97
97
|
const deepMerge = (element, extend, exclude = METHODS_EXL) => {
|
|
98
98
|
for (const e in extend) {
|
|
99
|
-
if (exclude.includes(e))
|
|
99
|
+
if (exclude.includes(e))
|
|
100
|
+
continue;
|
|
100
101
|
const elementProp = element[e];
|
|
101
102
|
const extendProp = extend[e];
|
|
102
103
|
if (elementProp === void 0) {
|
|
@@ -110,7 +111,8 @@ const deepMerge = (element, extend, exclude = METHODS_EXL) => {
|
|
|
110
111
|
const clone = (obj, exclude = METHODS_EXL) => {
|
|
111
112
|
const o = {};
|
|
112
113
|
for (const e in obj) {
|
|
113
|
-
if (exclude.includes(e))
|
|
114
|
+
if (exclude.includes(e))
|
|
115
|
+
continue;
|
|
114
116
|
o[e] = obj[e];
|
|
115
117
|
}
|
|
116
118
|
return o;
|
|
@@ -120,27 +122,31 @@ const overwrite = (element, params, options) => {
|
|
|
120
122
|
const { __ref } = element;
|
|
121
123
|
const { __exec, __cached } = __ref;
|
|
122
124
|
for (const e in params) {
|
|
123
|
-
if (e === "props" || e === "state" || e === "__ref")
|
|
125
|
+
if (e === "props" || e === "state" || e === "__ref")
|
|
126
|
+
continue;
|
|
124
127
|
const elementProp = element[e];
|
|
125
128
|
const paramsProp = params[e];
|
|
126
129
|
if (paramsProp !== void 0) {
|
|
127
130
|
__cached[e] = changes[e] = elementProp;
|
|
128
131
|
element[e] = paramsProp;
|
|
129
132
|
}
|
|
130
|
-
if (options.cleanExec)
|
|
133
|
+
if (options.cleanExec)
|
|
134
|
+
delete __exec[e];
|
|
131
135
|
}
|
|
132
136
|
return changes;
|
|
133
137
|
};
|
|
134
138
|
const overwriteShallow = (obj, params, exclude = METHODS_EXL) => {
|
|
135
139
|
for (const e in params) {
|
|
136
|
-
if (exclude.includes(e))
|
|
140
|
+
if (exclude.includes(e))
|
|
141
|
+
continue;
|
|
137
142
|
obj[e] = params[e];
|
|
138
143
|
}
|
|
139
144
|
return obj;
|
|
140
145
|
};
|
|
141
146
|
const overwriteDeep = (obj, params, exclude = METHODS_EXL) => {
|
|
142
147
|
for (const e in params) {
|
|
143
|
-
if (exclude.includes(e))
|
|
148
|
+
if (exclude.includes(e))
|
|
149
|
+
continue;
|
|
144
150
|
const objProp = obj[e];
|
|
145
151
|
const paramsProp = params[e];
|
|
146
152
|
if ((0, import_utils.isObjectLike)(objProp) && (0, import_utils.isObjectLike)(paramsProp)) {
|
|
@@ -152,7 +158,8 @@ const overwriteDeep = (obj, params, exclude = METHODS_EXL) => {
|
|
|
152
158
|
return obj;
|
|
153
159
|
};
|
|
154
160
|
const mergeIfExisted = (a, b) => {
|
|
155
|
-
if ((0, import_utils.isObjectLike)(a) && (0, import_utils.isObjectLike)(b))
|
|
161
|
+
if ((0, import_utils.isObjectLike)(a) && (0, import_utils.isObjectLike)(b))
|
|
162
|
+
return deepMerge(a, b);
|
|
156
163
|
return a || b;
|
|
157
164
|
};
|
|
158
165
|
const mergeArray = (arr, exclude = ["parent", "node", "__element", "state", "context", "__ref"]) => {
|
|
@@ -165,7 +172,8 @@ const flattenRecursive = (param, prop, stack = []) => {
|
|
|
165
172
|
const objectized = mergeAndCloneIfArray(param);
|
|
166
173
|
stack.push(objectized);
|
|
167
174
|
const extendOfExtend = objectized[prop];
|
|
168
|
-
if (extendOfExtend)
|
|
175
|
+
if (extendOfExtend)
|
|
176
|
+
flattenRecursive(extendOfExtend, prop, stack);
|
|
169
177
|
delete objectized[prop];
|
|
170
178
|
return stack;
|
|
171
179
|
};
|
|
@@ -36,15 +36,24 @@ const onlyResolveExtends = (element, parent, key, options) => {
|
|
|
36
36
|
element.tag = (0, import_render.detectTag)(element);
|
|
37
37
|
{
|
|
38
38
|
const { __ref: ref2 } = element;
|
|
39
|
-
if (!ref2.__cached)
|
|
40
|
-
|
|
41
|
-
if (!ref2.
|
|
42
|
-
|
|
43
|
-
if (!ref2.
|
|
44
|
-
|
|
45
|
-
if (!ref2.
|
|
46
|
-
|
|
47
|
-
if (!ref2.
|
|
39
|
+
if (!ref2.__cached)
|
|
40
|
+
ref2.__cached = {};
|
|
41
|
+
if (!ref2.__defineCache)
|
|
42
|
+
ref2.__defineCache = {};
|
|
43
|
+
if (!ref2.__exec)
|
|
44
|
+
ref2.__exec = {};
|
|
45
|
+
if (!ref2.__execProps)
|
|
46
|
+
ref2.__execProps = {};
|
|
47
|
+
if (!ref2.__class)
|
|
48
|
+
ref2.__class = {};
|
|
49
|
+
if (!ref2.__classNames)
|
|
50
|
+
ref2.__classNames = {};
|
|
51
|
+
if (!ref2.__attr)
|
|
52
|
+
ref2.__attr = {};
|
|
53
|
+
if (!ref2.__changes)
|
|
54
|
+
ref2.__changes = [];
|
|
55
|
+
if (!ref2.__children)
|
|
56
|
+
ref2.__children = [];
|
|
48
57
|
}
|
|
49
58
|
(0, import_set.addMethods)(element, parent, options);
|
|
50
59
|
(0, import_state.createState)(element, parent);
|
|
@@ -53,8 +62,10 @@ const onlyResolveExtends = (element, parent, key, options) => {
|
|
|
53
62
|
const ifPassed = element.if(element, element.state, element.context);
|
|
54
63
|
if (!ifPassed) {
|
|
55
64
|
delete ref.__if;
|
|
56
|
-
} else
|
|
57
|
-
|
|
65
|
+
} else
|
|
66
|
+
ref.__if = true;
|
|
67
|
+
} else
|
|
68
|
+
ref.__if = true;
|
|
58
69
|
if (element.node && ref.__if) {
|
|
59
70
|
parent[key || element.key] = element;
|
|
60
71
|
}
|
|
@@ -65,7 +76,8 @@ const onlyResolveExtends = (element, parent, key, options) => {
|
|
|
65
76
|
(0, import_iterate.throughInitialExec)(element);
|
|
66
77
|
for (const param in element) {
|
|
67
78
|
const prop = element[param];
|
|
68
|
-
if ((0, import_utils.isUndefined)(prop) || (0, import_methods.isMethod)(param, element) || (0, import_utils.isObject)(import_mixins.REGISTRY[param]) || (0, import__2.isVariant)(param))
|
|
79
|
+
if ((0, import_utils.isUndefined)(prop) || (0, import_methods.isMethod)(param, element) || (0, import_utils.isObject)(import_mixins.REGISTRY[param]) || (0, import__2.isVariant)(param))
|
|
80
|
+
continue;
|
|
69
81
|
const hasDefine = element.define && element.define[param];
|
|
70
82
|
const contextHasDefine = element.context && element.context.define && element.context.define[param];
|
|
71
83
|
const optionsHasDefine = options.define && options.define[param];
|
|
@@ -83,6 +95,7 @@ const onlyResolveExtends = (element, parent, key, options) => {
|
|
|
83
95
|
delete element.props.update;
|
|
84
96
|
delete element.props.__element;
|
|
85
97
|
}
|
|
86
|
-
if (!options.keepRef)
|
|
98
|
+
if (!options.keepRef)
|
|
99
|
+
delete element.__ref;
|
|
87
100
|
return element;
|
|
88
101
|
};
|
|
@@ -32,8 +32,10 @@ const propagateEventsFromProps = (element) => {
|
|
|
32
32
|
if ((0, import_utils.isFunction)(origEvent)) {
|
|
33
33
|
on[eventName] = (...args) => {
|
|
34
34
|
const originalEventRetunrs = origEvent(...args);
|
|
35
|
-
if (originalEventRetunrs !== false)
|
|
35
|
+
if (originalEventRetunrs !== false)
|
|
36
|
+
funcFromProps(...args);
|
|
36
37
|
};
|
|
37
|
-
} else
|
|
38
|
+
} else
|
|
39
|
+
on[eventName] = funcFromProps;
|
|
38
40
|
});
|
|
39
41
|
};
|