@domql/element 2.31.37 → 2.32.1
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/iterate.js +25 -7
- package/dist/cjs/mixins/attr.js +12 -3
- package/dist/cjs/mixins/classList.js +8 -8
- package/dist/cjs/mixins/content.js +6 -4
- package/dist/cjs/mixins/html.js +2 -2
- package/dist/cjs/mixins/state.js +2 -2
- package/dist/cjs/mixins/text.js +2 -2
- package/dist/cjs/node.js +2 -3
- package/dist/cjs/props/create.js +7 -4
- package/dist/cjs/props/update.js +4 -3
- package/dist/cjs/set.js +36 -9
- package/dist/cjs/update.js +11 -9
- package/dist/cjs/utils/applyParam.js +7 -1
- package/dist/esm/iterate.js +25 -7
- package/dist/esm/mixins/attr.js +12 -3
- package/dist/esm/mixins/classList.js +8 -8
- package/dist/esm/mixins/content.js +6 -4
- package/dist/esm/mixins/html.js +2 -2
- package/dist/esm/mixins/state.js +2 -2
- package/dist/esm/mixins/text.js +3 -6
- package/dist/esm/node.js +2 -3
- package/dist/esm/props/create.js +7 -4
- package/dist/esm/props/update.js +4 -3
- package/dist/esm/set.js +36 -9
- package/dist/esm/update.js +11 -9
- package/dist/esm/utils/applyParam.js +7 -1
- package/iterate.js +25 -7
- package/mixins/attr.js +12 -3
- package/mixins/classList.js +14 -9
- package/mixins/content.js +7 -8
- package/mixins/html.js +4 -2
- package/mixins/state.js +2 -2
- package/mixins/text.js +3 -6
- package/node.js +3 -3
- package/package.json +6 -6
- package/props/create.js +14 -9
- package/props/update.js +4 -3
- package/set.js +44 -29
- package/update.js +14 -9
- package/utils/applyParam.js +7 -1
package/dist/cjs/iterate.js
CHANGED
|
@@ -66,7 +66,7 @@ const throughUpdatedExec = async (element, options = { excludes: import_utils2.M
|
|
|
66
66
|
}
|
|
67
67
|
return changes;
|
|
68
68
|
};
|
|
69
|
-
const throughExecProps = (element) => {
|
|
69
|
+
const throughExecProps = (element, opts) => {
|
|
70
70
|
const { __ref: ref } = element;
|
|
71
71
|
const { props } = element;
|
|
72
72
|
for (const k in props) {
|
|
@@ -75,14 +75,20 @@ const throughExecProps = (element) => {
|
|
|
75
75
|
return import_methods.warn.call(element, "Element was not initiated to execute props");
|
|
76
76
|
const cachedExecProp = ref.__execProps[k];
|
|
77
77
|
if ((0, import_utils.isFunction)(cachedExecProp)) {
|
|
78
|
-
props[k] = (0, import_utils.exec)(
|
|
78
|
+
props[k] = (0, import_utils.exec)(
|
|
79
|
+
cachedExecProp,
|
|
80
|
+
element,
|
|
81
|
+
element.state,
|
|
82
|
+
element.context,
|
|
83
|
+
opts
|
|
84
|
+
);
|
|
79
85
|
} else if (isDefine && (0, import_utils.isFunction)(props[k])) {
|
|
80
86
|
ref.__execProps[k] = props[k];
|
|
81
|
-
props[k] = (0, import_utils.exec)(props[k], element);
|
|
87
|
+
props[k] = (0, import_utils.exec)(props[k], element, element.state, element.context, opts);
|
|
82
88
|
}
|
|
83
89
|
}
|
|
84
90
|
};
|
|
85
|
-
const throughInitialDefine = async (element) => {
|
|
91
|
+
const throughInitialDefine = async (element, opts) => {
|
|
86
92
|
const { define, context, __ref: ref } = element;
|
|
87
93
|
let defineObj = {};
|
|
88
94
|
const hasGlobalDefine = context && (0, import_utils.isObject)(context.define);
|
|
@@ -92,7 +98,13 @@ const throughInitialDefine = async (element) => {
|
|
|
92
98
|
let elementProp = element[param];
|
|
93
99
|
if ((0, import_utils.isFunction)(elementProp) && !(0, import_methods.isMethod)(param, element) && !(0, import_utils.isVariant)(param)) {
|
|
94
100
|
ref.__exec[param] = elementProp;
|
|
95
|
-
const execParam2 = elementProp = await (0, import_utils.exec)(
|
|
101
|
+
const execParam2 = elementProp = await (0, import_utils.exec)(
|
|
102
|
+
elementProp,
|
|
103
|
+
element,
|
|
104
|
+
element.state,
|
|
105
|
+
element.context,
|
|
106
|
+
opts
|
|
107
|
+
);
|
|
96
108
|
if (execParam2) {
|
|
97
109
|
elementProp = element[param] = execParam2.parse ? execParam2.parse() : execParam2;
|
|
98
110
|
ref.__defineCache[param] = elementProp;
|
|
@@ -108,7 +120,7 @@ const throughInitialDefine = async (element) => {
|
|
|
108
120
|
}
|
|
109
121
|
return element;
|
|
110
122
|
};
|
|
111
|
-
const throughUpdatedDefine = async (element) => {
|
|
123
|
+
const throughUpdatedDefine = async (element, opts) => {
|
|
112
124
|
const { context, define, __ref: ref } = element;
|
|
113
125
|
const changes = {};
|
|
114
126
|
let obj = {};
|
|
@@ -122,7 +134,13 @@ const throughUpdatedDefine = async (element) => {
|
|
|
122
134
|
element.state,
|
|
123
135
|
element.context
|
|
124
136
|
);
|
|
125
|
-
const cached = await (0, import_utils.exec)(
|
|
137
|
+
const cached = await (0, import_utils.exec)(
|
|
138
|
+
ref.__defineCache[param],
|
|
139
|
+
element,
|
|
140
|
+
element.state,
|
|
141
|
+
element.context,
|
|
142
|
+
opts
|
|
143
|
+
);
|
|
126
144
|
const newExecParam = await obj[param](
|
|
127
145
|
cached,
|
|
128
146
|
element,
|
package/dist/cjs/mixins/attr.js
CHANGED
|
@@ -25,16 +25,25 @@ module.exports = __toCommonJS(attr_exports);
|
|
|
25
25
|
var import_utils = require("@domql/utils");
|
|
26
26
|
var import_report = require("@domql/report");
|
|
27
27
|
var import_utils2 = require("../utils/index.js");
|
|
28
|
-
function attr(params, element, node) {
|
|
28
|
+
function attr(params, element, node, opts) {
|
|
29
29
|
const { __ref: ref, props } = element;
|
|
30
30
|
const { __attr } = ref;
|
|
31
31
|
if ((0, import_utils.isNot)("object")) (0, import_report.report)("HTMLInvalidAttr", params);
|
|
32
32
|
if (params) {
|
|
33
33
|
if (props.attr) (0, import_utils2.deepMerge)(params, props.attr);
|
|
34
34
|
for (const attr2 in params) {
|
|
35
|
-
const val = (0, import_utils.exec)(
|
|
35
|
+
const val = (0, import_utils.exec)(
|
|
36
|
+
params[attr2],
|
|
37
|
+
element,
|
|
38
|
+
element.state,
|
|
39
|
+
element.context,
|
|
40
|
+
opts
|
|
41
|
+
);
|
|
36
42
|
if (val !== false && !(0, import_utils.isUndefined)(val) && !(0, import_utils.isNull)(val) && node.setAttribute)
|
|
37
|
-
node.setAttribute(
|
|
43
|
+
node.setAttribute(
|
|
44
|
+
attr2,
|
|
45
|
+
(0, import_utils.exec)(val, element, element.state, element.context, opts)
|
|
46
|
+
);
|
|
38
47
|
else if (node.removeAttribute) node.removeAttribute(attr2);
|
|
39
48
|
__attr[attr2] = val;
|
|
40
49
|
}
|
|
@@ -34,34 +34,34 @@ const assignKeyAsClassname = (element) => {
|
|
|
34
34
|
element.class = key.slice(1);
|
|
35
35
|
}
|
|
36
36
|
};
|
|
37
|
-
const classify = (obj, element) => {
|
|
37
|
+
const classify = (obj, element, opts) => {
|
|
38
38
|
let className = "";
|
|
39
39
|
for (const item in obj) {
|
|
40
40
|
const param = obj[item];
|
|
41
41
|
if (typeof param === "boolean" && param) className += ` ${item}`;
|
|
42
42
|
else if (typeof param === "string") className += ` ${param}`;
|
|
43
43
|
else if (typeof param === "function") {
|
|
44
|
-
className += ` ${(0, import_utils.exec)(param, element)}`;
|
|
44
|
+
className += ` ${(0, import_utils.exec)(param, element, element.state, element.context, opts)}`;
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
return className;
|
|
48
48
|
};
|
|
49
|
-
const classList = (params, element) => {
|
|
49
|
+
const classList = (params, element, opts) => {
|
|
50
50
|
if (!params) return;
|
|
51
51
|
const { key } = element;
|
|
52
52
|
if (params === true) params = element.class = { key };
|
|
53
53
|
if ((0, import_utils.isString)(params)) params = element.class = { default: params };
|
|
54
|
-
if ((0, import_utils.isObject)(params)) params = classify(params, element);
|
|
54
|
+
if ((0, import_utils.isObject)(params)) params = classify(params, element, opts);
|
|
55
55
|
const className = params.replace(/\s+/g, " ").trim();
|
|
56
56
|
if (element.ref) element.ref.class = className;
|
|
57
57
|
return className;
|
|
58
58
|
};
|
|
59
|
-
const applyClassListOnNode = (params, element, node) => {
|
|
60
|
-
const className = classList(params, element);
|
|
59
|
+
const applyClassListOnNode = (params, element, node, opts) => {
|
|
60
|
+
const className = classList(params, element, opts);
|
|
61
61
|
node.classList = className;
|
|
62
62
|
return className;
|
|
63
63
|
};
|
|
64
|
-
function applyClasslist(params, element, node) {
|
|
65
|
-
applyClassListOnNode(params, element, node);
|
|
64
|
+
function applyClasslist(params, element, node, opts) {
|
|
65
|
+
applyClassListOnNode(params, element, node, opts);
|
|
66
66
|
}
|
|
67
67
|
var classList_default = applyClasslist;
|
|
@@ -51,10 +51,12 @@ const removeContent = function(el, opts = {}) {
|
|
|
51
51
|
}
|
|
52
52
|
const { __cached } = ref;
|
|
53
53
|
if (__cached && __cached[contentElementKey]) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
54
|
+
const cachedContent = __cached[contentElementKey];
|
|
55
|
+
if (cachedContent.tag === "fragment")
|
|
56
|
+
cachedContent.parent.node.innerHTML = "";
|
|
57
|
+
else if (cachedContent && (0, import_utils.isFunction)(cachedContent.remove))
|
|
58
|
+
cachedContent.remove();
|
|
59
|
+
delete __cached[contentElementKey];
|
|
58
60
|
}
|
|
59
61
|
ref.__children.splice(ref.__children.indexOf(contentElementKey), 1);
|
|
60
62
|
delete element[contentElementKey];
|
package/dist/cjs/mixins/html.js
CHANGED
|
@@ -23,9 +23,9 @@ __export(html_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(html_exports);
|
|
25
25
|
var import_utils = require("@domql/utils");
|
|
26
|
-
function html(param, element, node) {
|
|
26
|
+
function html(param, element, node, opts) {
|
|
27
27
|
var _a;
|
|
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);
|
|
28
|
+
const prop = (0, import_utils.exec)(param, element, element.state, element.context, opts) || (0, import_utils.exec)((_a = element == null ? void 0 : element.props) == null ? void 0 : _a.html, element, element.state, element.context, opts);
|
|
29
29
|
const { __ref } = element;
|
|
30
30
|
if (prop !== __ref.__html) {
|
|
31
31
|
if (node.nodeName === "SVG") node.textContent = prop;
|
package/dist/cjs/mixins/state.js
CHANGED
|
@@ -24,8 +24,8 @@ __export(state_exports, {
|
|
|
24
24
|
module.exports = __toCommonJS(state_exports);
|
|
25
25
|
var import_state = require("@domql/state");
|
|
26
26
|
var import_utils = require("@domql/utils");
|
|
27
|
-
async function state(params, element, node) {
|
|
28
|
-
const state2 = (0, import_utils.exec)(params, element);
|
|
27
|
+
async function state(params, element, node, opts) {
|
|
28
|
+
const state2 = (0, import_utils.exec)(params, element, element.state, element.context, opts);
|
|
29
29
|
if ((0, import_utils.isObject)(state2)) {
|
|
30
30
|
for (const param in state2) {
|
|
31
31
|
if (import_state.IGNORE_STATE_PARAMS.includes(param)) continue;
|
package/dist/cjs/mixins/text.js
CHANGED
|
@@ -24,8 +24,8 @@ __export(text_exports, {
|
|
|
24
24
|
module.exports = __toCommonJS(text_exports);
|
|
25
25
|
var import_create = require("../create.js");
|
|
26
26
|
var import_utils = require("@domql/utils");
|
|
27
|
-
function text(param, element, node) {
|
|
28
|
-
let prop = (0, import_utils.exec)(param, element);
|
|
27
|
+
function text(param, element, node, opts) {
|
|
28
|
+
let prop = (0, import_utils.exec)(param, element, element.state, element.context, opts);
|
|
29
29
|
if ((0, import_utils.isString)(prop) && prop.includes("{{")) {
|
|
30
30
|
prop = element.call("replaceLiteralsWithObjectFields", prop);
|
|
31
31
|
}
|
package/dist/cjs/node.js
CHANGED
|
@@ -31,7 +31,6 @@ var import_iterate = require("./iterate.js");
|
|
|
31
31
|
var import_mixins = require("./mixins/index.js");
|
|
32
32
|
var import_applyParam = require("./utils/applyParam.js");
|
|
33
33
|
var import_propEvents = require("./utils/propEvents.js");
|
|
34
|
-
var import_env = require("@domql/utils/env.js");
|
|
35
34
|
const createNode = async (element, options) => {
|
|
36
35
|
let { node, tag, __ref: ref } = element;
|
|
37
36
|
let isNewNode;
|
|
@@ -48,8 +47,8 @@ const createNode = async (element, options) => {
|
|
|
48
47
|
}
|
|
49
48
|
node.ref = element;
|
|
50
49
|
if ((0, import_utils.isFunction)(node.setAttribute)) node.setAttribute("key", element.key);
|
|
51
|
-
(0, import_iterate.throughExecProps)(element);
|
|
52
|
-
await (0, import_iterate.throughInitialDefine)(element);
|
|
50
|
+
(0, import_iterate.throughExecProps)(element, options);
|
|
51
|
+
await (0, import_iterate.throughInitialDefine)(element, options);
|
|
53
52
|
await (0, import_iterate.throughInitialExec)(element);
|
|
54
53
|
if (element.tag !== "string" && element.tag !== "fragment") {
|
|
55
54
|
(0, import_propEvents.propagateEventsFromProps)(element);
|
package/dist/cjs/props/create.js
CHANGED
|
@@ -46,7 +46,7 @@ const syncProps = async (props, element, opts) => {
|
|
|
46
46
|
if (import_ignore.IGNORE_PROPS_PARAMS.includes(v)) return;
|
|
47
47
|
let execProps;
|
|
48
48
|
try {
|
|
49
|
-
execProps = (0, import_utils.exec)(v, element);
|
|
49
|
+
execProps = (0, import_utils.exec)(v, element, element.state, element.context, opts);
|
|
50
50
|
} catch (e) {
|
|
51
51
|
element.error(e, opts);
|
|
52
52
|
}
|
|
@@ -57,7 +57,10 @@ const syncProps = async (props, element, opts) => {
|
|
|
57
57
|
);
|
|
58
58
|
});
|
|
59
59
|
element.props = mergedProps;
|
|
60
|
-
const methods = {
|
|
60
|
+
const methods = {
|
|
61
|
+
update: await update.bind(element.props),
|
|
62
|
+
__element: element
|
|
63
|
+
};
|
|
61
64
|
Object.setPrototypeOf(element.props, methods);
|
|
62
65
|
return element.props;
|
|
63
66
|
};
|
|
@@ -67,7 +70,7 @@ const createProps = function(element, parent, options) {
|
|
|
67
70
|
const propsStack = options.cachedProps || createPropsStack(element, parent);
|
|
68
71
|
if (propsStack.length) {
|
|
69
72
|
ref.__props = propsStack;
|
|
70
|
-
syncProps(propsStack, element);
|
|
73
|
+
syncProps(propsStack, element, options);
|
|
71
74
|
} else {
|
|
72
75
|
ref.__props = options.cachedProps || [];
|
|
73
76
|
element.props = {};
|
|
@@ -80,7 +83,7 @@ const createProps = function(element, parent, options) {
|
|
|
80
83
|
} catch (e) {
|
|
81
84
|
element.props = {};
|
|
82
85
|
ref.__props = options.cachedProps || [];
|
|
83
|
-
element.error("Error applying props", e);
|
|
86
|
+
element.error("Error applying props", e, options);
|
|
84
87
|
}
|
|
85
88
|
}
|
|
86
89
|
const methods = { update: update.bind(element.props), __element: element };
|
package/dist/cjs/props/update.js
CHANGED
|
@@ -23,12 +23,13 @@ __export(update_exports, {
|
|
|
23
23
|
module.exports = __toCommonJS(update_exports);
|
|
24
24
|
var import_create = require("./create.js");
|
|
25
25
|
var import_inherit = require("./inherit.js");
|
|
26
|
-
const updateProps = (newProps, element, parent) => {
|
|
26
|
+
const updateProps = (newProps, element, parent, opts) => {
|
|
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)
|
|
30
|
+
if (parentProps.length)
|
|
31
|
+
propsStack = __ref.__props = [].concat(parentProps, propsStack);
|
|
31
32
|
if (newProps) propsStack = __ref.__props = [].concat(newProps, propsStack);
|
|
32
|
-
if (propsStack) (0, import_create.syncProps)(propsStack, element);
|
|
33
|
+
if (propsStack) (0, import_create.syncProps)(propsStack, element, opts);
|
|
33
34
|
return element;
|
|
34
35
|
};
|
package/dist/cjs/set.js
CHANGED
|
@@ -33,12 +33,20 @@ var import_event = require("@domql/event");
|
|
|
33
33
|
const resetElement = async (params, element, options) => {
|
|
34
34
|
if (!options.preventRemove) (0, import_content.removeContent)(element, options);
|
|
35
35
|
const { __ref: ref } = element;
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
36
|
+
const contentElementKey = (0, import_utils.setContentKey)(element, options);
|
|
37
|
+
const { __cached } = ref;
|
|
38
|
+
const newContent = await (0, import_create.create)(
|
|
39
|
+
params,
|
|
40
|
+
element,
|
|
41
|
+
ref.contentElementKey || "content",
|
|
42
|
+
{
|
|
43
|
+
ignoreChildExtend: true,
|
|
44
|
+
...import_mixins.registry.defaultOptions,
|
|
45
|
+
...import_options.OPTIONS.create,
|
|
46
|
+
...options
|
|
47
|
+
}
|
|
48
|
+
);
|
|
49
|
+
__cached[contentElementKey] = newContent;
|
|
42
50
|
};
|
|
43
51
|
const reset = async (options) => {
|
|
44
52
|
const element = void 0;
|
|
@@ -50,16 +58,35 @@ const reset = async (options) => {
|
|
|
50
58
|
});
|
|
51
59
|
};
|
|
52
60
|
const set = async function(params, options = {}, el) {
|
|
53
|
-
var _a, _b, _c;
|
|
61
|
+
var _a, _b, _c, _d;
|
|
54
62
|
const element = el || this;
|
|
63
|
+
const { __ref: ref } = element;
|
|
55
64
|
if (options.preventContentUpdate || options.preventUpdate && ((_b = (_a = options.preventUpdate).includes) == null ? void 0 : _b.call(_a, "content")))
|
|
56
65
|
return;
|
|
57
66
|
if (options.routerContentElement && options.lastElement) {
|
|
58
67
|
if (options.routerContentElement !== options.lastElement.content) return;
|
|
59
68
|
}
|
|
69
|
+
const contentKey = (0, import_utils.setContentKey)(element, options);
|
|
70
|
+
const content = element[contentKey];
|
|
71
|
+
const __contentRef = content && content.__ref;
|
|
60
72
|
const lazyLoad = element.props && element.props.lazyLoad;
|
|
61
|
-
const hasCollection = element.$collection || element.$stateCollection || element.$propsCollection;
|
|
73
|
+
const hasCollection = element.$collection || element.$stateCollection || element.$propsCollection || ((_c = element.props) == null ? void 0 : _c.children);
|
|
62
74
|
if (options.preventContentUpdate === true && !hasCollection) return;
|
|
75
|
+
if (!options.forceReset && (ref.__noCollectionDifference || __contentRef && __contentRef.__cached && (0, import_utils.deepContains)(params, content))) {
|
|
76
|
+
if (!options.preventBeforeUpdateListener && !options.preventListeners) {
|
|
77
|
+
const beforeUpdateReturns = await (0, import_event.triggerEventOnUpdate)(
|
|
78
|
+
"beforeUpdate",
|
|
79
|
+
params,
|
|
80
|
+
element,
|
|
81
|
+
options
|
|
82
|
+
);
|
|
83
|
+
if (beforeUpdateReturns === false) return element;
|
|
84
|
+
}
|
|
85
|
+
if (content == null ? void 0 : content.update) await content.update({}, options);
|
|
86
|
+
if (!options.preventUpdateListener)
|
|
87
|
+
await (0, import_event.triggerEventOn)("update", element, options);
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
63
90
|
if (params) {
|
|
64
91
|
let { childExtend, props } = params;
|
|
65
92
|
if (!props) props = params.props = {};
|
|
@@ -67,7 +94,7 @@ const set = async function(params, options = {}, el) {
|
|
|
67
94
|
params.childExtend = element.childExtend;
|
|
68
95
|
props.ignoreChildExtend = true;
|
|
69
96
|
}
|
|
70
|
-
if (!(props == null ? void 0 : props.childProps) && ((
|
|
97
|
+
if (!(props == null ? void 0 : props.childProps) && ((_d = element.props) == null ? void 0 : _d.childProps)) {
|
|
71
98
|
props.childProps = element.props.childProps;
|
|
72
99
|
props.ignoreChildProps = true;
|
|
73
100
|
}
|
package/dist/cjs/update.js
CHANGED
|
@@ -60,27 +60,27 @@ const update = async function(params = {}, opts) {
|
|
|
60
60
|
element,
|
|
61
61
|
options
|
|
62
62
|
);
|
|
63
|
-
if (snapshotHasUpdated) return;
|
|
64
|
-
if (checkIfStorm(element, options)) return;
|
|
63
|
+
if (snapshotHasUpdated) return false;
|
|
64
|
+
if (checkIfStorm(element, options)) return false;
|
|
65
65
|
if (!options.preventListeners)
|
|
66
66
|
await (0, import_event.triggerEventOn)("eventStart", element, options);
|
|
67
67
|
if (!options.preventListeners)
|
|
68
68
|
await (0, import_event.triggerEventOnUpdate)("startUpdate", params, element, options);
|
|
69
69
|
if (preventInheritAtCurrentState && preventInheritAtCurrentState.__element === element)
|
|
70
|
-
return;
|
|
70
|
+
return false;
|
|
71
71
|
if (!excludes) (0, import_utils.merge)(options, UPDATE_DEFAULT_OPTIONS);
|
|
72
72
|
if ((0, import_utils.isString)(params) || (0, import_utils.isNumber)(params)) {
|
|
73
73
|
params = { text: params };
|
|
74
74
|
}
|
|
75
75
|
const inheritState = await inheritStateUpdates(element, options);
|
|
76
|
-
if (inheritState === false) return;
|
|
76
|
+
if (inheritState === false) return false;
|
|
77
77
|
const ifFails = checkIfOnUpdate(element, parent, options);
|
|
78
|
-
if (ifFails) return;
|
|
78
|
+
if (ifFails) return false;
|
|
79
79
|
if (ref.__if && !options.preventPropsUpdate) {
|
|
80
80
|
const hasParentProps = parent.props && (parent.props[key] || parent.props.childProps);
|
|
81
81
|
const hasFunctionInProps = ref.__props.filter((v) => (0, import_utils.isFunction)(v));
|
|
82
82
|
const props = params.props || hasParentProps || hasFunctionInProps.length;
|
|
83
|
-
if (props) (0, import_props.updateProps)(props, element, parent);
|
|
83
|
+
if (props) (0, import_props.updateProps)(props, element, parent, options);
|
|
84
84
|
}
|
|
85
85
|
if (!options.preventBeforeUpdateListener && !options.preventListeners) {
|
|
86
86
|
const beforeUpdateReturns = await (0, import_event.triggerEventOnUpdate)(
|
|
@@ -92,15 +92,17 @@ const update = async function(params = {}, opts) {
|
|
|
92
92
|
if (beforeUpdateReturns === false) return element;
|
|
93
93
|
}
|
|
94
94
|
(0, import_utils.overwriteDeep)(element, params, { exclude: import_utils2.METHODS_EXL });
|
|
95
|
-
(0, import_iterate.throughExecProps)(element);
|
|
95
|
+
(0, import_iterate.throughExecProps)(element, options);
|
|
96
96
|
await (0, import_iterate.throughUpdatedExec)(element, { ignore: UPDATE_DEFAULT_OPTIONS });
|
|
97
|
-
await (0, import_iterate.throughUpdatedDefine)(element);
|
|
97
|
+
await (0, import_iterate.throughUpdatedDefine)(element, options);
|
|
98
98
|
if (!options.isForced && !options.preventListeners) {
|
|
99
99
|
await (0, import_event.triggerEventOn)("beforeClassAssign", element, options);
|
|
100
100
|
}
|
|
101
101
|
if (!ref.__if) return false;
|
|
102
102
|
if (!node) {
|
|
103
|
-
return;
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
if (element.tag !== "fragment" && !document.body.contains(node)) {
|
|
104
106
|
}
|
|
105
107
|
const {
|
|
106
108
|
preventUpdate,
|
|
@@ -25,7 +25,13 @@ var import_utils = require("@domql/utils");
|
|
|
25
25
|
var import_mixins = require("../mixins/index.js");
|
|
26
26
|
const applyParam = async (param, element, options) => {
|
|
27
27
|
const { node, context, __ref: ref } = element;
|
|
28
|
-
const prop = await (0, import_utils.exec)(
|
|
28
|
+
const prop = await (0, import_utils.exec)(
|
|
29
|
+
element[param],
|
|
30
|
+
element,
|
|
31
|
+
element.state,
|
|
32
|
+
element.context,
|
|
33
|
+
options
|
|
34
|
+
);
|
|
29
35
|
const { onlyUpdate } = options;
|
|
30
36
|
const DOMQLProperty = import_mixins.REGISTRY[param];
|
|
31
37
|
const DOMQLPropertyFromContext = context && context.registry && context.registry[param];
|
package/dist/esm/iterate.js
CHANGED
|
@@ -48,7 +48,7 @@ const throughUpdatedExec = async (element, options = { excludes: METHODS_EXL })
|
|
|
48
48
|
}
|
|
49
49
|
return changes;
|
|
50
50
|
};
|
|
51
|
-
const throughExecProps = (element) => {
|
|
51
|
+
const throughExecProps = (element, opts) => {
|
|
52
52
|
const { __ref: ref } = element;
|
|
53
53
|
const { props } = element;
|
|
54
54
|
for (const k in props) {
|
|
@@ -57,14 +57,20 @@ const throughExecProps = (element) => {
|
|
|
57
57
|
return warn.call(element, "Element was not initiated to execute props");
|
|
58
58
|
const cachedExecProp = ref.__execProps[k];
|
|
59
59
|
if (isFunction(cachedExecProp)) {
|
|
60
|
-
props[k] = exec(
|
|
60
|
+
props[k] = exec(
|
|
61
|
+
cachedExecProp,
|
|
62
|
+
element,
|
|
63
|
+
element.state,
|
|
64
|
+
element.context,
|
|
65
|
+
opts
|
|
66
|
+
);
|
|
61
67
|
} else if (isDefine && isFunction(props[k])) {
|
|
62
68
|
ref.__execProps[k] = props[k];
|
|
63
|
-
props[k] = exec(props[k], element);
|
|
69
|
+
props[k] = exec(props[k], element, element.state, element.context, opts);
|
|
64
70
|
}
|
|
65
71
|
}
|
|
66
72
|
};
|
|
67
|
-
const throughInitialDefine = async (element) => {
|
|
73
|
+
const throughInitialDefine = async (element, opts) => {
|
|
68
74
|
const { define, context, __ref: ref } = element;
|
|
69
75
|
let defineObj = {};
|
|
70
76
|
const hasGlobalDefine = context && isObject(context.define);
|
|
@@ -74,7 +80,13 @@ const throughInitialDefine = async (element) => {
|
|
|
74
80
|
let elementProp = element[param];
|
|
75
81
|
if (isFunction(elementProp) && !isMethod(param, element) && !isVariant(param)) {
|
|
76
82
|
ref.__exec[param] = elementProp;
|
|
77
|
-
const execParam2 = elementProp = await exec(
|
|
83
|
+
const execParam2 = elementProp = await exec(
|
|
84
|
+
elementProp,
|
|
85
|
+
element,
|
|
86
|
+
element.state,
|
|
87
|
+
element.context,
|
|
88
|
+
opts
|
|
89
|
+
);
|
|
78
90
|
if (execParam2) {
|
|
79
91
|
elementProp = element[param] = execParam2.parse ? execParam2.parse() : execParam2;
|
|
80
92
|
ref.__defineCache[param] = elementProp;
|
|
@@ -90,7 +102,7 @@ const throughInitialDefine = async (element) => {
|
|
|
90
102
|
}
|
|
91
103
|
return element;
|
|
92
104
|
};
|
|
93
|
-
const throughUpdatedDefine = async (element) => {
|
|
105
|
+
const throughUpdatedDefine = async (element, opts) => {
|
|
94
106
|
const { context, define, __ref: ref } = element;
|
|
95
107
|
const changes = {};
|
|
96
108
|
let obj = {};
|
|
@@ -104,7 +116,13 @@ const throughUpdatedDefine = async (element) => {
|
|
|
104
116
|
element.state,
|
|
105
117
|
element.context
|
|
106
118
|
);
|
|
107
|
-
const cached = await exec(
|
|
119
|
+
const cached = await exec(
|
|
120
|
+
ref.__defineCache[param],
|
|
121
|
+
element,
|
|
122
|
+
element.state,
|
|
123
|
+
element.context,
|
|
124
|
+
opts
|
|
125
|
+
);
|
|
108
126
|
const newExecParam = await obj[param](
|
|
109
127
|
cached,
|
|
110
128
|
element,
|
package/dist/esm/mixins/attr.js
CHANGED
|
@@ -1,16 +1,25 @@
|
|
|
1
1
|
import { exec, isNot, isNull, isUndefined } from "@domql/utils";
|
|
2
2
|
import { report } from "@domql/report";
|
|
3
3
|
import { deepMerge } from "../utils/index.js";
|
|
4
|
-
function attr(params, element, node) {
|
|
4
|
+
function attr(params, element, node, opts) {
|
|
5
5
|
const { __ref: ref, props } = element;
|
|
6
6
|
const { __attr } = ref;
|
|
7
7
|
if (isNot("object")) report("HTMLInvalidAttr", params);
|
|
8
8
|
if (params) {
|
|
9
9
|
if (props.attr) deepMerge(params, props.attr);
|
|
10
10
|
for (const attr2 in params) {
|
|
11
|
-
const val = exec(
|
|
11
|
+
const val = exec(
|
|
12
|
+
params[attr2],
|
|
13
|
+
element,
|
|
14
|
+
element.state,
|
|
15
|
+
element.context,
|
|
16
|
+
opts
|
|
17
|
+
);
|
|
12
18
|
if (val !== false && !isUndefined(val) && !isNull(val) && node.setAttribute)
|
|
13
|
-
node.setAttribute(
|
|
19
|
+
node.setAttribute(
|
|
20
|
+
attr2,
|
|
21
|
+
exec(val, element, element.state, element.context, opts)
|
|
22
|
+
);
|
|
14
23
|
else if (node.removeAttribute) node.removeAttribute(attr2);
|
|
15
24
|
__attr[attr2] = val;
|
|
16
25
|
}
|
|
@@ -6,35 +6,35 @@ const assignKeyAsClassname = (element) => {
|
|
|
6
6
|
element.class = key.slice(1);
|
|
7
7
|
}
|
|
8
8
|
};
|
|
9
|
-
const classify = (obj, element) => {
|
|
9
|
+
const classify = (obj, element, opts) => {
|
|
10
10
|
let className = "";
|
|
11
11
|
for (const item in obj) {
|
|
12
12
|
const param = obj[item];
|
|
13
13
|
if (typeof param === "boolean" && param) className += ` ${item}`;
|
|
14
14
|
else if (typeof param === "string") className += ` ${param}`;
|
|
15
15
|
else if (typeof param === "function") {
|
|
16
|
-
className += ` ${exec(param, element)}`;
|
|
16
|
+
className += ` ${exec(param, element, element.state, element.context, opts)}`;
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
return className;
|
|
20
20
|
};
|
|
21
|
-
const classList = (params, element) => {
|
|
21
|
+
const classList = (params, element, opts) => {
|
|
22
22
|
if (!params) return;
|
|
23
23
|
const { key } = element;
|
|
24
24
|
if (params === true) params = element.class = { key };
|
|
25
25
|
if (isString(params)) params = element.class = { default: params };
|
|
26
|
-
if (isObject(params)) params = classify(params, element);
|
|
26
|
+
if (isObject(params)) params = classify(params, element, opts);
|
|
27
27
|
const className = params.replace(/\s+/g, " ").trim();
|
|
28
28
|
if (element.ref) element.ref.class = className;
|
|
29
29
|
return className;
|
|
30
30
|
};
|
|
31
|
-
const applyClassListOnNode = (params, element, node) => {
|
|
32
|
-
const className = classList(params, element);
|
|
31
|
+
const applyClassListOnNode = (params, element, node, opts) => {
|
|
32
|
+
const className = classList(params, element, opts);
|
|
33
33
|
node.classList = className;
|
|
34
34
|
return className;
|
|
35
35
|
};
|
|
36
|
-
function applyClasslist(params, element, node) {
|
|
37
|
-
applyClassListOnNode(params, element, node);
|
|
36
|
+
function applyClasslist(params, element, node, opts) {
|
|
37
|
+
applyClassListOnNode(params, element, node, opts);
|
|
38
38
|
}
|
|
39
39
|
var classList_default = applyClasslist;
|
|
40
40
|
export {
|
|
@@ -25,10 +25,12 @@ const removeContent = function(el, opts = {}) {
|
|
|
25
25
|
}
|
|
26
26
|
const { __cached } = ref;
|
|
27
27
|
if (__cached && __cached[contentElementKey]) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
const cachedContent = __cached[contentElementKey];
|
|
29
|
+
if (cachedContent.tag === "fragment")
|
|
30
|
+
cachedContent.parent.node.innerHTML = "";
|
|
31
|
+
else if (cachedContent && isFunction(cachedContent.remove))
|
|
32
|
+
cachedContent.remove();
|
|
33
|
+
delete __cached[contentElementKey];
|
|
32
34
|
}
|
|
33
35
|
ref.__children.splice(ref.__children.indexOf(contentElementKey), 1);
|
|
34
36
|
delete element[contentElementKey];
|
package/dist/esm/mixins/html.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { exec } from "@domql/utils";
|
|
2
|
-
function html(param, element, node) {
|
|
2
|
+
function html(param, element, node, opts) {
|
|
3
3
|
var _a;
|
|
4
|
-
const prop = exec(param, element) || exec((_a = element == null ? void 0 : element.props) == null ? void 0 : _a.html, element);
|
|
4
|
+
const prop = exec(param, element, element.state, element.context, opts) || exec((_a = element == null ? void 0 : element.props) == null ? void 0 : _a.html, element, element.state, element.context, opts);
|
|
5
5
|
const { __ref } = element;
|
|
6
6
|
if (prop !== __ref.__html) {
|
|
7
7
|
if (node.nodeName === "SVG") node.textContent = prop;
|
package/dist/esm/mixins/state.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { IGNORE_STATE_PARAMS } from "@domql/state";
|
|
2
2
|
import { exec, isObject } from "@domql/utils";
|
|
3
|
-
async function state(params, element, node) {
|
|
4
|
-
const state2 = exec(params, element);
|
|
3
|
+
async function state(params, element, node, opts) {
|
|
4
|
+
const state2 = exec(params, element, element.state, element.context, opts);
|
|
5
5
|
if (isObject(state2)) {
|
|
6
6
|
for (const param in state2) {
|
|
7
7
|
if (IGNORE_STATE_PARAMS.includes(param)) continue;
|
package/dist/esm/mixins/text.js
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { create } from "../create.js";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
} from "@domql/utils";
|
|
6
|
-
function text(param, element, node) {
|
|
7
|
-
let prop = exec(param, element);
|
|
2
|
+
import { exec, isString } from "@domql/utils";
|
|
3
|
+
function text(param, element, node, opts) {
|
|
4
|
+
let prop = exec(param, element, element.state, element.context, opts);
|
|
8
5
|
if (isString(prop) && prop.includes("{{")) {
|
|
9
6
|
prop = element.call("replaceLiteralsWithObjectFields", prop);
|
|
10
7
|
}
|
package/dist/esm/node.js
CHANGED
|
@@ -17,7 +17,6 @@ import {
|
|
|
17
17
|
import { REGISTRY } from "./mixins/index.js";
|
|
18
18
|
import { applyParam } from "./utils/applyParam.js";
|
|
19
19
|
import { propagateEventsFromProps } from "./utils/propEvents.js";
|
|
20
|
-
import { isNotProduction } from "@domql/utils/env.js";
|
|
21
20
|
const createNode = async (element, options) => {
|
|
22
21
|
let { node, tag, __ref: ref } = element;
|
|
23
22
|
let isNewNode;
|
|
@@ -34,8 +33,8 @@ const createNode = async (element, options) => {
|
|
|
34
33
|
}
|
|
35
34
|
node.ref = element;
|
|
36
35
|
if (isFunction(node.setAttribute)) node.setAttribute("key", element.key);
|
|
37
|
-
throughExecProps(element);
|
|
38
|
-
await throughInitialDefine(element);
|
|
36
|
+
throughExecProps(element, options);
|
|
37
|
+
await throughInitialDefine(element, options);
|
|
39
38
|
await throughInitialExec(element);
|
|
40
39
|
if (element.tag !== "string" && element.tag !== "fragment") {
|
|
41
40
|
propagateEventsFromProps(element);
|