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