@domql/element 2.5.198 → 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
package/dist/cjs/mixins/attr.js
CHANGED
|
@@ -28,17 +28,13 @@ 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"))
|
|
32
|
-
(0, import_report.report)("HTMLInvalidAttr", params);
|
|
31
|
+
if ((0, import_utils.isNot)("object")) (0, import_report.report)("HTMLInvalidAttr", params);
|
|
33
32
|
if (params) {
|
|
34
|
-
if (props.attr)
|
|
35
|
-
(0, import_utils2.deepMerge)(params, props.attr);
|
|
33
|
+
if (props.attr) (0, import_utils2.deepMerge)(params, props.attr);
|
|
36
34
|
for (const attr2 in params) {
|
|
37
35
|
const val = (0, import_utils.exec)(params[attr2], element);
|
|
38
|
-
if (val !== false && !(0, import_utils.isUndefined)(val) && !(0, import_utils.isNull)(val) && node.setAttribute)
|
|
39
|
-
|
|
40
|
-
else if (node.removeAttribute)
|
|
41
|
-
node.removeAttribute(attr2);
|
|
36
|
+
if (val !== false && !(0, import_utils.isUndefined)(val) && !(0, import_utils.isNull)(val) && node.setAttribute) node.setAttribute(attr2, val);
|
|
37
|
+
else if (node.removeAttribute) node.removeAttribute(attr2);
|
|
42
38
|
__attr[attr2] = val;
|
|
43
39
|
}
|
|
44
40
|
}
|
|
@@ -29,8 +29,7 @@ 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)
|
|
33
|
-
element.class = key;
|
|
32
|
+
if (element.class === true) element.class = key;
|
|
34
33
|
else if (!element.class && typeof key === "string" && key.charAt(0) === "_" && key.charAt(1) !== "_") {
|
|
35
34
|
element.class = key.slice(1);
|
|
36
35
|
}
|
|
@@ -39,10 +38,8 @@ const classify = (obj, element) => {
|
|
|
39
38
|
let className = "";
|
|
40
39
|
for (const item in obj) {
|
|
41
40
|
const param = obj[item];
|
|
42
|
-
if (typeof param === "boolean" && param)
|
|
43
|
-
|
|
44
|
-
else if (typeof param === "string")
|
|
45
|
-
className += ` ${param}`;
|
|
41
|
+
if (typeof param === "boolean" && param) className += ` ${item}`;
|
|
42
|
+
else if (typeof param === "string") className += ` ${param}`;
|
|
46
43
|
else if (typeof param === "function") {
|
|
47
44
|
className += ` ${(0, import_utils.exec)(param, element)}`;
|
|
48
45
|
}
|
|
@@ -50,18 +47,13 @@ const classify = (obj, element) => {
|
|
|
50
47
|
return className;
|
|
51
48
|
};
|
|
52
49
|
const classList = (params, element) => {
|
|
53
|
-
if (!params)
|
|
54
|
-
return;
|
|
50
|
+
if (!params) return;
|
|
55
51
|
const { key } = element;
|
|
56
|
-
if (params === true)
|
|
57
|
-
|
|
58
|
-
if ((0, import_utils.
|
|
59
|
-
params = element.class = { default: params };
|
|
60
|
-
if ((0, import_utils.isObject)(params))
|
|
61
|
-
params = classify(params, element);
|
|
52
|
+
if (params === true) params = element.class = { key };
|
|
53
|
+
if ((0, import_utils.isString)(params)) params = element.class = { default: params };
|
|
54
|
+
if ((0, import_utils.isObject)(params)) params = classify(params, element);
|
|
62
55
|
const className = params.replace(/\s+/g, " ").trim();
|
|
63
|
-
if (element.ref)
|
|
64
|
-
element.ref.class = className;
|
|
56
|
+
if (element.ref) element.ref.class = className;
|
|
65
57
|
return className;
|
|
66
58
|
};
|
|
67
59
|
const applyClassListOnNode = (params, element, node) => {
|
|
@@ -30,33 +30,26 @@ 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
|
-
|
|
35
|
-
if (element[contentKey].update)
|
|
36
|
-
element[contentKey].update(params, options);
|
|
33
|
+
if (!element[contentKey]) return;
|
|
34
|
+
if (element[contentKey].update) element[contentKey].update(params, options);
|
|
37
35
|
};
|
|
38
36
|
const removeContent = function(el, opts = {}) {
|
|
39
37
|
const element = el || this;
|
|
40
38
|
const { __ref: ref } = element;
|
|
41
39
|
const contentElementKey = (0, import_utils.setContentKey)(element, opts);
|
|
42
|
-
if (opts.contentElementKey !== "content")
|
|
43
|
-
opts.contentElementKey = "content";
|
|
40
|
+
if (opts.contentElementKey !== "content") opts.contentElementKey = "content";
|
|
44
41
|
if (element[contentElementKey]) {
|
|
45
42
|
if (element[contentElementKey].node && element.node) {
|
|
46
|
-
if (element[contentElementKey].tag === "fragment")
|
|
47
|
-
element.node.innerHTML = "";
|
|
43
|
+
if (element[contentElementKey].tag === "fragment") element.node.innerHTML = "";
|
|
48
44
|
else {
|
|
49
45
|
const contentNode = element[contentElementKey].node;
|
|
50
|
-
if (contentNode.parentNode === element.node)
|
|
51
|
-
element.node.removeChild(element[contentElementKey].node);
|
|
46
|
+
if (contentNode.parentNode === element.node) element.node.removeChild(element[contentElementKey].node);
|
|
52
47
|
}
|
|
53
48
|
}
|
|
54
49
|
const { __cached } = ref;
|
|
55
50
|
if (__cached && __cached[contentElementKey]) {
|
|
56
|
-
if (__cached[contentElementKey].tag === "fragment")
|
|
57
|
-
|
|
58
|
-
else if (__cached[contentElementKey] && (0, import_utils.isFunction)(__cached[contentElementKey].remove))
|
|
59
|
-
__cached[contentElementKey].remove();
|
|
51
|
+
if (__cached[contentElementKey].tag === "fragment") __cached[contentElementKey].parent.node.innerHTML = "";
|
|
52
|
+
else if (__cached[contentElementKey] && (0, import_utils.isFunction)(__cached[contentElementKey].remove)) __cached[contentElementKey].remove();
|
|
60
53
|
}
|
|
61
54
|
delete element[contentElementKey];
|
|
62
55
|
}
|
package/dist/cjs/mixins/data.js
CHANGED
|
@@ -26,11 +26,9 @@ 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)
|
|
30
|
-
(0, import_utils.deepMerge)(params, element.props.data);
|
|
29
|
+
if (element.props.data) (0, import_utils.deepMerge)(params, element.props.data);
|
|
31
30
|
if (params.showOnNode) {
|
|
32
|
-
if (!(0, import_utils.isObject)(params))
|
|
33
|
-
(0, import_report.report)("HTMLInvalidData", params);
|
|
31
|
+
if (!(0, import_utils.isObject)(params)) (0, import_report.report)("HTMLInvalidData", params);
|
|
34
32
|
for (const dataset in params) {
|
|
35
33
|
if (dataset !== "showOnNode") {
|
|
36
34
|
node.dataset[dataset] = (0, import_utils.exec)(params[dataset], element);
|
package/dist/cjs/mixins/html.js
CHANGED
|
@@ -28,10 +28,8 @@ 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
|
-
|
|
33
|
-
else
|
|
34
|
-
node.innerHTML = prop;
|
|
31
|
+
if (node.nodeName === "SVG") node.textContent = prop;
|
|
32
|
+
else node.innerHTML = prop;
|
|
35
33
|
__ref.__html = prop;
|
|
36
34
|
}
|
|
37
35
|
}
|
package/dist/cjs/mixins/scope.js
CHANGED
|
@@ -24,8 +24,7 @@ __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))
|
|
28
|
-
return;
|
|
27
|
+
if (!(0, import_utils.isObject)(params)) return;
|
|
29
28
|
for (const scopeItem in params) {
|
|
30
29
|
const value = params[scopeItem];
|
|
31
30
|
if ((0, import_utils.isFunction)(value)) {
|
package/dist/cjs/mixins/state.js
CHANGED
|
@@ -28,10 +28,8 @@ 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
|
-
|
|
33
|
-
if (!Object.hasOwnProperty.call(state2, param))
|
|
34
|
-
continue;
|
|
31
|
+
if (import_state.IGNORE_STATE_PARAMS.includes(param)) continue;
|
|
32
|
+
if (!Object.hasOwnProperty.call(state2, param)) continue;
|
|
35
33
|
}
|
|
36
34
|
}
|
|
37
35
|
return element;
|
package/dist/cjs/mixins/style.js
CHANGED
|
@@ -26,10 +26,8 @@ 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
|
-
|
|
31
|
-
else
|
|
32
|
-
(0, import_report.report)("HTMLInvalidStyles", params);
|
|
29
|
+
if ((0, import_utils.isObject)(params)) (0, import_utils.map)(node.style, params, element);
|
|
30
|
+
else (0, import_report.report)("HTMLInvalidStyles", params);
|
|
33
31
|
}
|
|
34
32
|
}
|
|
35
33
|
var style_default = style;
|
package/dist/cjs/mixins/text.js
CHANGED
|
@@ -33,13 +33,10 @@ 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)
|
|
37
|
-
return;
|
|
36
|
+
if (element.__text.text === prop) return;
|
|
38
37
|
element.__text.text = prop;
|
|
39
|
-
if (element.__text.node)
|
|
40
|
-
|
|
41
|
-
} else
|
|
42
|
-
(0, import_create.create)({ tag: "string", text: prop }, element, "__text");
|
|
38
|
+
if (element.__text.node) element.__text.node.nodeValue = prop;
|
|
39
|
+
} else (0, import_create.create)({ tag: "string", text: prop }, element, "__text");
|
|
43
40
|
}
|
|
44
41
|
}
|
|
45
42
|
var text_default = text;
|
package/dist/cjs/node.js
CHANGED
|
@@ -37,18 +37,15 @@ const createNode = async (element, options) => {
|
|
|
37
37
|
let isNewNode;
|
|
38
38
|
if (!node) {
|
|
39
39
|
isNewNode = true;
|
|
40
|
-
if (!ref.__if)
|
|
41
|
-
return element;
|
|
40
|
+
if (!ref.__if) return element;
|
|
42
41
|
if (tag === "shadow") {
|
|
43
42
|
node = element.node = element.parent.node.attachShadow({ mode: "open" });
|
|
44
|
-
} else
|
|
45
|
-
node = element.node = (0, import_render.cacheNode)(element);
|
|
43
|
+
} else node = element.node = (0, import_render.cacheNode)(element);
|
|
46
44
|
(0, import_event.triggerEventOn)("attachNode", element, options);
|
|
47
45
|
}
|
|
48
46
|
if (ENV === "test" || ENV === "development" || options.alowRefReference) {
|
|
49
47
|
node.ref = element;
|
|
50
|
-
if ((0, import_utils.isFunction)(node.setAttribute))
|
|
51
|
-
node.setAttribute("key", element.key);
|
|
48
|
+
if ((0, import_utils.isFunction)(node.setAttribute)) node.setAttribute("key", element.key);
|
|
52
49
|
}
|
|
53
50
|
(0, import_iterate.throughExecProps)(element);
|
|
54
51
|
(0, import_iterate.throughInitialDefine)(element);
|
|
@@ -61,10 +58,8 @@ const createNode = async (element, options) => {
|
|
|
61
58
|
}
|
|
62
59
|
for (const param in element) {
|
|
63
60
|
const value = element[param];
|
|
64
|
-
if (!Object.hasOwnProperty.call(element, param))
|
|
65
|
-
|
|
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;
|
|
61
|
+
if (!Object.hasOwnProperty.call(element, param)) continue;
|
|
62
|
+
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])) continue;
|
|
68
63
|
const isElement = (0, import_applyParam.applyParam)(param, element, options);
|
|
69
64
|
if (isElement) {
|
|
70
65
|
const { hasDefine, hasContextDefine } = isElement;
|
|
@@ -79,8 +74,7 @@ const createNode = async (element, options) => {
|
|
|
79
74
|
(0, import_event.triggerEventOn)("lazyLoad", element, options);
|
|
80
75
|
}
|
|
81
76
|
});
|
|
82
|
-
} else
|
|
83
|
-
await createAsync();
|
|
77
|
+
} else await createAsync();
|
|
84
78
|
}
|
|
85
79
|
}
|
|
86
80
|
}
|
package/dist/cjs/props/create.js
CHANGED
|
@@ -28,16 +28,12 @@ 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
|
|
34
|
-
propsStack.push(parent.props);
|
|
35
|
-
else if (props)
|
|
36
|
-
propsStack.push(props);
|
|
31
|
+
if ((0, import_utils.isObject)(props)) propsStack.push(props);
|
|
32
|
+
else if (props === "inherit" && parent.props) propsStack.push(parent.props);
|
|
33
|
+
else if (props) propsStack.push(props);
|
|
37
34
|
if ((0, import_utils.isArray)(ref.__extend)) {
|
|
38
35
|
ref.__extend.forEach((extend) => {
|
|
39
|
-
if (extend.props && extend.props !== props)
|
|
40
|
-
propsStack.push(extend.props);
|
|
36
|
+
if (extend.props && extend.props !== props) propsStack.push(extend.props);
|
|
41
37
|
});
|
|
42
38
|
}
|
|
43
39
|
ref.__props = propsStack;
|
|
@@ -47,8 +43,7 @@ const syncProps = (props, element, opts) => {
|
|
|
47
43
|
element.props = {};
|
|
48
44
|
const mergedProps = {};
|
|
49
45
|
props.forEach((v) => {
|
|
50
|
-
if (import_ignore.IGNORE_PROPS_PARAMS.includes(v))
|
|
51
|
-
return;
|
|
46
|
+
if (import_ignore.IGNORE_PROPS_PARAMS.includes(v)) return;
|
|
52
47
|
let execProps;
|
|
53
48
|
try {
|
|
54
49
|
execProps = (0, import_utils.exec)(v, element);
|
|
@@ -78,8 +73,7 @@ const createProps = function(element, parent, options) {
|
|
|
78
73
|
element.props = {};
|
|
79
74
|
}
|
|
80
75
|
};
|
|
81
|
-
if (ref.__if)
|
|
82
|
-
applyProps();
|
|
76
|
+
if (ref.__if) applyProps();
|
|
83
77
|
else {
|
|
84
78
|
try {
|
|
85
79
|
applyProps();
|
|
@@ -38,8 +38,7 @@ 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)
|
|
42
|
-
inheritedStringExists.inheritedString = matchParent;
|
|
41
|
+
if (inheritedStringExists) inheritedStringExists.inheritedString = matchParent;
|
|
43
42
|
else {
|
|
44
43
|
propsStack = [].concat(objectizeStringProperty(matchParent), propsStack);
|
|
45
44
|
}
|
|
@@ -47,7 +46,6 @@ const inheritParentProps = (element, parent) => {
|
|
|
47
46
|
propsStack.push(objectizeStringProperty(matchParent));
|
|
48
47
|
}
|
|
49
48
|
}
|
|
50
|
-
if (matchParentChildProps && !((_a = element == null ? void 0 : element.props) == null ? void 0 : _a.ignoreChildProps))
|
|
51
|
-
propsStack.push(matchParentChildProps);
|
|
49
|
+
if (matchParentChildProps && !((_a = element == null ? void 0 : element.props) == null ? void 0 : _a.ignoreChildProps)) propsStack.push(matchParentChildProps);
|
|
52
50
|
return propsStack;
|
|
53
51
|
};
|
package/dist/cjs/props/update.js
CHANGED
|
@@ -27,11 +27,8 @@ 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 (
|
|
33
|
-
propsStack = __ref.__props = [].concat(newProps, propsStack);
|
|
34
|
-
if (propsStack)
|
|
35
|
-
(0, import_create.syncProps)(propsStack, element);
|
|
30
|
+
if (parentProps.length) propsStack = __ref.__props = [].concat(parentProps, propsStack);
|
|
31
|
+
if (newProps) propsStack = __ref.__props = [].concat(newProps, propsStack);
|
|
32
|
+
if (propsStack) (0, import_create.syncProps)(propsStack, element);
|
|
36
33
|
return element;
|
|
37
34
|
};
|
package/dist/cjs/set.js
CHANGED
|
@@ -31,8 +31,7 @@ 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)
|
|
35
|
-
(0, import_content.removeContent)(element, options);
|
|
34
|
+
if (!options.preventRemove) (0, import_content.removeContent)(element, options);
|
|
36
35
|
const { __ref: ref } = element;
|
|
37
36
|
await (0, import_create.create)(params, element, ref.contentElementKey || "content", {
|
|
38
37
|
ignoreChildExtend: true,
|
|
@@ -58,24 +57,19 @@ const set = async function(params, options = {}, el) {
|
|
|
58
57
|
const __contentRef = content && content.__ref;
|
|
59
58
|
const lazyLoad = element.props && element.props.lazyLoad;
|
|
60
59
|
const hasCollection = element.$collection || element.$stateCollection || element.$propsCollection;
|
|
61
|
-
if (options.preventContentUpdate === true && !hasCollection)
|
|
62
|
-
return;
|
|
60
|
+
if (options.preventContentUpdate === true && !hasCollection) return;
|
|
63
61
|
if (ref.__noCollectionDifference || __contentRef && __contentRef.__cached && (0, import_utils.deepContains)(params, content)) {
|
|
64
62
|
if (!options.preventBeforeUpdateListener && !options.preventListeners) {
|
|
65
63
|
const beforeUpdateReturns = await (0, import_event.triggerEventOnUpdate)("beforeUpdate", params, element, options);
|
|
66
|
-
if (beforeUpdateReturns === false)
|
|
67
|
-
return element;
|
|
64
|
+
if (beforeUpdateReturns === false) return element;
|
|
68
65
|
}
|
|
69
|
-
if (content == null ? void 0 : content.update)
|
|
70
|
-
|
|
71
|
-
if (!options.preventUpdateListener)
|
|
72
|
-
await (0, import_event.triggerEventOn)("update", element, options);
|
|
66
|
+
if (content == null ? void 0 : content.update) content.update();
|
|
67
|
+
if (!options.preventUpdateListener) await (0, import_event.triggerEventOn)("update", element, options);
|
|
73
68
|
return;
|
|
74
69
|
}
|
|
75
70
|
if (params) {
|
|
76
71
|
let { childExtend, props } = params;
|
|
77
|
-
if (!props)
|
|
78
|
-
props = params.props = {};
|
|
72
|
+
if (!props) props = params.props = {};
|
|
79
73
|
if (!childExtend && element.childExtend) {
|
|
80
74
|
params.childExtend = element.childExtend;
|
|
81
75
|
props.ignoreChildExtend = true;
|
|
@@ -91,8 +85,7 @@ const set = async function(params, options = {}, el) {
|
|
|
91
85
|
(0, import_event.triggerEventOn)("lazyLoad", element, options);
|
|
92
86
|
}
|
|
93
87
|
});
|
|
94
|
-
} else
|
|
95
|
-
await resetElement(params, element, options);
|
|
88
|
+
} else await resetElement(params, element, options);
|
|
96
89
|
}
|
|
97
90
|
return element;
|
|
98
91
|
};
|
package/dist/cjs/update.js
CHANGED
|
@@ -52,37 +52,28 @@ 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)
|
|
56
|
-
ref = element.__ref = {};
|
|
55
|
+
if (!ref) ref = element.__ref = {};
|
|
57
56
|
const [snapshotOnCallee, calleeElement, snapshotHasUpdated] = captureSnapshot(element, options);
|
|
58
|
-
if (snapshotHasUpdated)
|
|
59
|
-
|
|
60
|
-
if (
|
|
61
|
-
|
|
62
|
-
if (preventInheritAtCurrentState && preventInheritAtCurrentState.__element === element)
|
|
63
|
-
return;
|
|
64
|
-
if (!excludes)
|
|
65
|
-
(0, import_utils.merge)(options, UPDATE_DEFAULT_OPTIONS);
|
|
57
|
+
if (snapshotHasUpdated) return;
|
|
58
|
+
if (!options.preventListeners) await (0, import_event.triggerEventOnUpdate)("startUpdate", params, element, options);
|
|
59
|
+
if (preventInheritAtCurrentState && preventInheritAtCurrentState.__element === element) return;
|
|
60
|
+
if (!excludes) (0, import_utils.merge)(options, UPDATE_DEFAULT_OPTIONS);
|
|
66
61
|
if ((0, import_utils.isString)(params) || (0, import_utils.isNumber)(params)) {
|
|
67
62
|
params = { text: params };
|
|
68
63
|
}
|
|
69
64
|
const inheritState = await inheritStateUpdates(element, options);
|
|
70
|
-
if (inheritState === false)
|
|
71
|
-
return;
|
|
65
|
+
if (inheritState === false) return;
|
|
72
66
|
const ifFails = checkIfOnUpdate(element, parent, options);
|
|
73
|
-
if (ifFails)
|
|
74
|
-
return;
|
|
67
|
+
if (ifFails) return;
|
|
75
68
|
if (ref.__if && !options.preventPropsUpdate) {
|
|
76
69
|
const hasParentProps = parent.props && (parent.props[key] || parent.props.childProps);
|
|
77
70
|
const hasFunctionInProps = ref.__props.filter((v) => (0, import_utils.isFunction)(v));
|
|
78
71
|
const props = params.props || hasParentProps || hasFunctionInProps.length;
|
|
79
|
-
if (props)
|
|
80
|
-
(0, import_props.updateProps)(props, element, parent);
|
|
72
|
+
if (props) (0, import_props.updateProps)(props, element, parent);
|
|
81
73
|
}
|
|
82
74
|
if (!options.preventBeforeUpdateListener && !options.preventListeners) {
|
|
83
75
|
const beforeUpdateReturns = await (0, import_event.triggerEventOnUpdate)("beforeUpdate", params, element, options);
|
|
84
|
-
if (beforeUpdateReturns === false)
|
|
85
|
-
return element;
|
|
76
|
+
if (beforeUpdateReturns === false) return element;
|
|
86
77
|
}
|
|
87
78
|
(0, import_utils.overwriteDeep)(element, params, { exclude: import_utils2.METHODS_EXL });
|
|
88
79
|
(0, import_iterate.throughExecProps)(element);
|
|
@@ -91,8 +82,7 @@ const update = async function(params = {}, opts) {
|
|
|
91
82
|
if (!options.isForced && !options.preventListeners) {
|
|
92
83
|
(0, import_event.triggerEventOn)("beforeClassAssign", element, options);
|
|
93
84
|
}
|
|
94
|
-
if (!ref.__if)
|
|
95
|
-
return false;
|
|
85
|
+
if (!ref.__if) return false;
|
|
96
86
|
if (!node) {
|
|
97
87
|
return;
|
|
98
88
|
}
|
|
@@ -107,30 +97,23 @@ const update = async function(params = {}, opts) {
|
|
|
107
97
|
preventUpdateAfterCount
|
|
108
98
|
} = options;
|
|
109
99
|
if (preventUpdateAfter) {
|
|
110
|
-
if ((0, import_utils.isNumber)(preventUpdateAfterCount) && preventUpdateAfter <= preventUpdateAfterCount)
|
|
111
|
-
|
|
112
|
-
else
|
|
113
|
-
options.preventUpdateAfterCount = 1;
|
|
114
|
-
else
|
|
115
|
-
options.preventUpdateAfterCount++;
|
|
100
|
+
if ((0, import_utils.isNumber)(preventUpdateAfterCount) && preventUpdateAfter <= preventUpdateAfterCount) return;
|
|
101
|
+
else if (options.preventUpdateAfterCount === void 0) options.preventUpdateAfterCount = 1;
|
|
102
|
+
else options.preventUpdateAfterCount++;
|
|
116
103
|
}
|
|
117
104
|
for (const param in element) {
|
|
118
105
|
const prop = element[param];
|
|
119
|
-
if (!Object.hasOwnProperty.call(element, param))
|
|
120
|
-
continue;
|
|
106
|
+
if (!Object.hasOwnProperty.call(element, param)) continue;
|
|
121
107
|
const isInPreventUpdate = (0, import_utils.isArray)(preventUpdate) && preventUpdate.includes(param);
|
|
122
108
|
const isInPreventDefineUpdate = (0, import_utils.isArray)(preventDefineUpdate) && preventDefineUpdate.includes(param);
|
|
123
109
|
const hasCollection = element.$collection || element.$stateCollection || element.$propsCollection;
|
|
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
|
-
|
|
126
|
-
if (preventStateUpdate === "once")
|
|
127
|
-
options.preventStateUpdate = false;
|
|
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)) continue;
|
|
111
|
+
if (preventStateUpdate === "once") options.preventStateUpdate = false;
|
|
128
112
|
const isElement = (0, import_applyParam.applyParam)(param, element, options);
|
|
129
113
|
if (isElement) {
|
|
130
114
|
const { hasDefine, hasContextDefine } = isElement;
|
|
131
115
|
const canUpdate = (0, import_utils.isObject)(prop) && !hasDefine && !hasContextDefine && !preventRecursive;
|
|
132
|
-
if (!canUpdate)
|
|
133
|
-
continue;
|
|
116
|
+
if (!canUpdate) continue;
|
|
134
117
|
const lazyLoad = element.props.lazyLoad || options.lazyLoad;
|
|
135
118
|
if (options.onEachUpdate) {
|
|
136
119
|
options.onEachUpdate(param, element, element.state, element.context);
|
|
@@ -148,8 +131,7 @@ const update = async function(params = {}, opts) {
|
|
|
148
131
|
}) : childUpdateCall();
|
|
149
132
|
}
|
|
150
133
|
}
|
|
151
|
-
if (!preventUpdateListener)
|
|
152
|
-
(0, import_event.triggerEventOn)("update", element, options);
|
|
134
|
+
if (!preventUpdateListener) (0, import_event.triggerEventOn)("update", element, options);
|
|
153
135
|
};
|
|
154
136
|
const captureSnapshot = (element, options) => {
|
|
155
137
|
const ref = element.__ref;
|
|
@@ -168,8 +150,7 @@ const captureSnapshot = (element, options) => {
|
|
|
168
150
|
};
|
|
169
151
|
const checkIfOnUpdate = (element, parent, options) => {
|
|
170
152
|
var _a, _b, _c;
|
|
171
|
-
if (!(0, import_utils.isFunction)(element.if) && !(0, import_utils.isFunction)((_a = element.props) == null ? void 0 : _a.if) || !parent)
|
|
172
|
-
return;
|
|
153
|
+
if (!(0, import_utils.isFunction)(element.if) && !(0, import_utils.isFunction)((_a = element.props) == null ? void 0 : _a.if) || !parent) return;
|
|
173
154
|
const ref = element.__ref;
|
|
174
155
|
const ifPassed = (element.if || ((_b = element.props) == null ? void 0 : _b.if))(element, element.state, element.context, options);
|
|
175
156
|
const itWasFalse = ref.__if !== true;
|
|
@@ -194,8 +175,7 @@ const checkIfOnUpdate = (element, parent, options) => {
|
|
|
194
175
|
const contentKey = ref.contentElementKey;
|
|
195
176
|
if (element.$collection || element.$stateCollection || element.$propsCollection) {
|
|
196
177
|
element.removeContent();
|
|
197
|
-
} else if ((_c = element[contentKey]) == null ? void 0 : _c.parseDeep)
|
|
198
|
-
element[contentKey] = element[contentKey].parseDeep();
|
|
178
|
+
} else if ((_c = element[contentKey]) == null ? void 0 : _c.parseDeep) element[contentKey] = element[contentKey].parseDeep();
|
|
199
179
|
const previousElement = element.previousElement();
|
|
200
180
|
const previousNode = previousElement == null ? void 0 : previousElement.node;
|
|
201
181
|
const hasPrevious = previousNode == null ? void 0 : previousNode.parentNode;
|
|
@@ -224,8 +204,7 @@ const inheritStateUpdates = async (element, options) => {
|
|
|
224
204
|
const stateKey = ref.__state;
|
|
225
205
|
const { parent, state } = element;
|
|
226
206
|
const { preventUpdateTriggerStateUpdate, isHoisted, execStateFunction } = options;
|
|
227
|
-
if (preventUpdateTriggerStateUpdate)
|
|
228
|
-
return;
|
|
207
|
+
if (preventUpdateTriggerStateUpdate) return;
|
|
229
208
|
if (!stateKey && !ref.__hasRootState) {
|
|
230
209
|
element.state = parent && parent.state || {};
|
|
231
210
|
return;
|
|
@@ -237,12 +216,10 @@ const inheritStateUpdates = async (element, options) => {
|
|
|
237
216
|
return;
|
|
238
217
|
}
|
|
239
218
|
const keyInParentState = (0, import_state.findInheritedState)(element, element.parent);
|
|
240
|
-
if (!keyInParentState || options.preventInheritedStateUpdate)
|
|
241
|
-
return;
|
|
219
|
+
if (!keyInParentState || options.preventInheritedStateUpdate) return;
|
|
242
220
|
if (!options.preventBeforeStateUpdateListener && !options.preventListeners) {
|
|
243
221
|
const initStateReturns = await (0, import_event.triggerEventOnUpdate)("beforeStateUpdate", keyInParentState, element, options);
|
|
244
|
-
if (initStateReturns === false)
|
|
245
|
-
return element;
|
|
222
|
+
if (initStateReturns === false) return element;
|
|
246
223
|
}
|
|
247
224
|
const newState = createStateUpdate(element, parent, options);
|
|
248
225
|
if (!options.preventStateUpdateListener && !options.preventListeners) {
|
|
@@ -254,8 +231,7 @@ const createStateUpdate = (element, parent, options) => {
|
|
|
254
231
|
const newState = (0, import_state.createState)(element, parent);
|
|
255
232
|
element.state = newState;
|
|
256
233
|
for (const child in __stateChildren) {
|
|
257
|
-
if (newState[child])
|
|
258
|
-
newState.__children[child] = __stateChildren[child];
|
|
234
|
+
if (newState[child]) newState.__children[child] = __stateChildren[child];
|
|
259
235
|
Object.getPrototypeOf(__stateChildren[child]).parent = newState;
|
|
260
236
|
}
|
|
261
237
|
return newState;
|
|
@@ -32,8 +32,7 @@ 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)
|
|
36
|
-
return;
|
|
35
|
+
if (!ref.__if) return;
|
|
37
36
|
const hasOnlyUpdate = onlyUpdate ? onlyUpdate === param || element.lookup(onlyUpdate) : true;
|
|
38
37
|
if (isGlobalTransformer && !hasContextDefine && hasOnlyUpdate) {
|
|
39
38
|
if ((0, import_utils.isFunction)(isGlobalTransformer)) {
|
|
@@ -46,8 +46,7 @@ const createValidDomqlObjectFromSugar = (el, parent, key, options) => {
|
|
|
46
46
|
};
|
|
47
47
|
const overwriteVariant = (element, variant, variantProps) => {
|
|
48
48
|
let variantElement = element[variant];
|
|
49
|
-
if (!variantElement)
|
|
50
|
-
return;
|
|
49
|
+
if (!variantElement) return;
|
|
51
50
|
const props = (0, import_utils.isObject)(variantProps) ? variantProps : {};
|
|
52
51
|
if ((0, import_utils.isString)(variantElement)) {
|
|
53
52
|
variantElement = {
|
|
@@ -62,16 +61,14 @@ const overwriteVariant = (element, variant, variantProps) => {
|
|
|
62
61
|
};
|
|
63
62
|
const applyVariant = (element) => {
|
|
64
63
|
const { props } = element;
|
|
65
|
-
if (!(0, import_utils.hasVariantProp)(element))
|
|
66
|
-
return element;
|
|
64
|
+
if (!(0, import_utils.hasVariantProp)(element)) return element;
|
|
67
65
|
const { variant } = props;
|
|
68
66
|
overwriteVariant(element, `.${variant}`);
|
|
69
67
|
const elKeys = Object.keys(element).filter((key) => (0, import_utils.isVariant)(key));
|
|
70
68
|
elKeys.forEach((variant2) => {
|
|
71
69
|
const slicedVariantElementKey = variant2.slice(1);
|
|
72
70
|
const variantElementProps = props[slicedVariantElementKey];
|
|
73
|
-
if (variantElementProps)
|
|
74
|
-
overwriteVariant(element, variant2, variantElementProps);
|
|
71
|
+
if (variantElementProps) overwriteVariant(element, variant2, variantElementProps);
|
|
75
72
|
});
|
|
76
73
|
return element;
|
|
77
74
|
};
|
|
@@ -69,21 +69,16 @@ 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.
|
|
75
|
-
return extractArrayExtend(extend, stack, context);
|
|
76
|
-
if ((0, import_utils.isString)(extend))
|
|
77
|
-
extend = fallbackStringExtend(extend, context);
|
|
72
|
+
if (!extend) return stack;
|
|
73
|
+
if ((0, import_utils.isArray)(extend)) return extractArrayExtend(extend, stack, context);
|
|
74
|
+
if ((0, import_utils.isString)(extend)) extend = fallbackStringExtend(extend, context);
|
|
78
75
|
stack.push(extend);
|
|
79
|
-
if (extend.extend)
|
|
80
|
-
deepExtend(extend, stack, context);
|
|
76
|
+
if (extend.extend) deepExtend(extend, stack, context);
|
|
81
77
|
return stack;
|
|
82
78
|
};
|
|
83
79
|
const deepMergeExtend = (element, extend) => {
|
|
84
80
|
for (const e in extend) {
|
|
85
|
-
if (["parent", "node", "__element"].indexOf(e) > -1)
|
|
86
|
-
continue;
|
|
81
|
+
if (["parent", "node", "__element"].indexOf(e) > -1) continue;
|
|
87
82
|
const elementProp = element[e];
|
|
88
83
|
const extendProp = extend[e];
|
|
89
84
|
if (elementProp === void 0) {
|
|
@@ -112,10 +107,8 @@ const fallbackStringExtend = (extend, context, options = {}, variant) => {
|
|
|
112
107
|
if ((0, import_utils.isString)(extend)) {
|
|
113
108
|
const componentExists = COMPONENTS && (COMPONENTS[extend + "." + variant] || COMPONENTS[extend] || COMPONENTS["smbls." + extend]);
|
|
114
109
|
const pageExists = PAGES && extend.startsWith("/") && PAGES[extend];
|
|
115
|
-
if (componentExists)
|
|
116
|
-
|
|
117
|
-
else if (pageExists)
|
|
118
|
-
return pageExists;
|
|
110
|
+
if (componentExists) return componentExists;
|
|
111
|
+
else if (pageExists) return pageExists;
|
|
119
112
|
else {
|
|
120
113
|
if (options.verbose && (ENV === "test" || ENV === "development")) {
|
|
121
114
|
console.warn("Extend is string but component was not found:", extend);
|
|
@@ -129,10 +122,8 @@ const jointStacks = (extendStack, childExtendStack) => {
|
|
|
129
122
|
return [].concat(extendStack.slice(0, 1)).concat(childExtendStack.slice(0, 1)).concat(extendStack.slice(1)).concat(childExtendStack.slice(1));
|
|
130
123
|
};
|
|
131
124
|
const getExtendStack = (extend, context) => {
|
|
132
|
-
if (!extend)
|
|
133
|
-
|
|
134
|
-
if (extend.__hash)
|
|
135
|
-
return getHashedExtend(extend) || [];
|
|
125
|
+
if (!extend) return [];
|
|
126
|
+
if (extend.__hash) return getHashedExtend(extend) || [];
|
|
136
127
|
const stack = flattenExtend(extend, [], context);
|
|
137
128
|
return getExtendStackRegistry(extend, stack);
|
|
138
129
|
};
|