@domql/element 2.5.18 → 2.5.19
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 +2 -0
- package/dist/cjs/mixins/text.js +0 -17
- package/dist/cjs/node.js +17 -17
- package/dist/cjs/utils/component.js +5 -1
- package/mixins/text.js +0 -13
- package/node.js +25 -26
- package/package.json +2 -2
- package/utils/component.js +5 -1
package/create.js
CHANGED
|
@@ -45,6 +45,8 @@ const ENV = process.env.NODE_ENV
|
|
|
45
45
|
const create = (element, parent, key, options = OPTIONS.create || {}) => {
|
|
46
46
|
cacheOptions(element, options)
|
|
47
47
|
|
|
48
|
+
// if (key === 'Title') debugger
|
|
49
|
+
|
|
48
50
|
// if element is STRING
|
|
49
51
|
if (checkIfPrimitive(element)) {
|
|
50
52
|
element = applyValueAsText(element, parent, key)
|
package/dist/cjs/mixins/text.js
CHANGED
|
@@ -18,34 +18,17 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var text_exports = {};
|
|
20
20
|
__export(text_exports, {
|
|
21
|
-
asd: () => asd,
|
|
22
21
|
default: () => text_default
|
|
23
22
|
});
|
|
24
23
|
module.exports = __toCommonJS(text_exports);
|
|
25
24
|
var import__ = require("..");
|
|
26
25
|
var import_utils = require("@domql/utils");
|
|
27
|
-
const asd = (param, element, node) => {
|
|
28
|
-
const prop = (0, import_utils.exec)(param, element);
|
|
29
|
-
if (element.tag === "string") {
|
|
30
|
-
node.nodeValue = prop;
|
|
31
|
-
} else if (param !== void 0 || param !== null) {
|
|
32
|
-
if (element.__text && element.__text.text !== prop)
|
|
33
|
-
return;
|
|
34
|
-
element.__text.text = prop;
|
|
35
|
-
if (element.__text.node)
|
|
36
|
-
element.__text.node.nodeValue = prop;
|
|
37
|
-
else
|
|
38
|
-
(0, import__.create)({ tag: "string", text: prop }, element, "__text");
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
26
|
var text_default = (param, element, node) => {
|
|
42
27
|
let prop = (0, import_utils.exec)(param, element);
|
|
43
28
|
if ((0, import_utils.isString)(prop) && prop.includes("{{")) {
|
|
44
29
|
prop = (0, import_utils.replaceLiteralsWithObjectFields)(prop, element.state);
|
|
45
30
|
}
|
|
46
31
|
if (element.tag === "string") {
|
|
47
|
-
if (element.text === prop)
|
|
48
|
-
return;
|
|
49
32
|
node.nodeValue = prop;
|
|
50
33
|
} else if (param !== void 0 || param !== null) {
|
|
51
34
|
if (element.__text) {
|
package/dist/cjs/node.js
CHANGED
|
@@ -60,25 +60,25 @@ const createNode = (element, options) => {
|
|
|
60
60
|
if ((0, import_utils.isFunction)(node.setAttribute))
|
|
61
61
|
node.setAttribute("key", element.key);
|
|
62
62
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
63
|
+
(0, import_iterate.throughInitialDefine)(element);
|
|
64
|
+
(0, import_iterate.throughInitialExec)(element);
|
|
65
|
+
if (element.tag !== "string" && element.tag !== "fragment") {
|
|
66
66
|
if (isNewNode && (0, import_utils.isObject)(element.on))
|
|
67
67
|
(0, import_event.applyEventsOnNode)(element);
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
68
|
+
}
|
|
69
|
+
for (const param in element) {
|
|
70
|
+
const value = element[param];
|
|
71
|
+
if ((0, import_utils.isUndefined)(value) || (0, import_methods.isMethod)(param) || (0, import_utils2.isVariant)(param) || (0, import_utils.isObject)(import_mixins.registry[param]))
|
|
72
|
+
continue;
|
|
73
|
+
const isElement = (0, import_applyParam.applyParam)(param, element, options);
|
|
74
|
+
if (isElement) {
|
|
75
|
+
const { hasDefine, hasContextDefine } = isElement;
|
|
76
|
+
if (element[param] && !hasDefine && !hasContextDefine) {
|
|
77
|
+
const createAsync = () => (0, import_create.default)((0, import_utils.exec)(value, element), element, param, options);
|
|
78
|
+
if (element.props && element.props.lazyLoad || options.lazyLoad) {
|
|
79
|
+
window.requestAnimationFrame(() => createAsync());
|
|
80
|
+
} else
|
|
81
|
+
createAsync();
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
}
|
|
@@ -48,25 +48,29 @@ const addAdditionalExtend = (newExtend, element) => {
|
|
|
48
48
|
};
|
|
49
49
|
};
|
|
50
50
|
const extendizeByKey = (element, parent, key) => {
|
|
51
|
-
const { extend, props, state, childExtend, childProps, on, if: condition } = element;
|
|
51
|
+
const { tag, extend, props, state, childExtend, childProps, on, if: condition } = element;
|
|
52
52
|
const hasComponentAttrs = extend || childExtend || props || state || on || condition;
|
|
53
53
|
const componentKey = key.includes("_") ? key.split("_")[0] : key.includes(".") ? key.split(".")[0] : key;
|
|
54
54
|
const extendKey = componentKey || key;
|
|
55
55
|
if (!hasComponentAttrs || childProps) {
|
|
56
56
|
return {
|
|
57
57
|
extend: extendKey,
|
|
58
|
+
tag,
|
|
58
59
|
props: { ...element }
|
|
59
60
|
};
|
|
60
61
|
} else if (!extend || extend === true) {
|
|
61
62
|
return {
|
|
62
63
|
...element,
|
|
64
|
+
tag,
|
|
63
65
|
extend: extendKey
|
|
64
66
|
};
|
|
65
67
|
} else if (extend) {
|
|
66
68
|
addAdditionalExtend(extendKey, element);
|
|
67
69
|
} else if ((0, import_utils.isFunction)(element)) {
|
|
70
|
+
console.log(element);
|
|
68
71
|
return {
|
|
69
72
|
extend: extendKey,
|
|
73
|
+
tag,
|
|
70
74
|
props: { ...(0, import_utils.exec)(element, parent) }
|
|
71
75
|
};
|
|
72
76
|
}
|
package/mixins/text.js
CHANGED
|
@@ -11,25 +11,12 @@ import {
|
|
|
11
11
|
* Creates a text node and appends into
|
|
12
12
|
* an original one as a child
|
|
13
13
|
*/
|
|
14
|
-
export const asd = (param, element, node) => {
|
|
15
|
-
const prop = exec(param, element)
|
|
16
|
-
if (element.tag === 'string') {
|
|
17
|
-
node.nodeValue = prop
|
|
18
|
-
} else if (param !== undefined || param !== null) {
|
|
19
|
-
if (element.__text && element.__text.text !== prop) return
|
|
20
|
-
element.__text.text = prop
|
|
21
|
-
if (element.__text.node) element.__text.node.nodeValue = prop
|
|
22
|
-
else create({ tag: 'string', text: prop }, element, '__text')
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
14
|
export default (param, element, node) => {
|
|
27
15
|
let prop = exec(param, element)
|
|
28
16
|
if (isString(prop) && prop.includes('{{')) {
|
|
29
17
|
prop = replaceLiteralsWithObjectFields(prop, element.state)
|
|
30
18
|
}
|
|
31
19
|
if (element.tag === 'string') {
|
|
32
|
-
if (element.text === prop) return
|
|
33
20
|
node.nodeValue = prop
|
|
34
21
|
} else if (param !== undefined || param !== null) {
|
|
35
22
|
if (element.__text) {
|
package/node.js
CHANGED
|
@@ -44,37 +44,36 @@ export const createNode = (element, options) => {
|
|
|
44
44
|
if (isFunction(node.setAttribute)) node.setAttribute('key', element.key)
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
// iterate through
|
|
48
|
-
|
|
49
|
-
// iterate through define
|
|
50
|
-
throughInitialDefine(element)
|
|
47
|
+
// iterate through define
|
|
48
|
+
throughInitialDefine(element)
|
|
51
49
|
|
|
52
|
-
|
|
53
|
-
|
|
50
|
+
// iterate through exec
|
|
51
|
+
throughInitialExec(element)
|
|
54
52
|
|
|
53
|
+
if (element.tag !== 'string' && element.tag !== 'fragment') {
|
|
55
54
|
// apply events
|
|
56
55
|
if (isNewNode && isObject(element.on)) applyEventsOnNode(element)
|
|
56
|
+
}
|
|
57
57
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}
|
|
58
|
+
for (const param in element) {
|
|
59
|
+
const value = element[param]
|
|
60
|
+
|
|
61
|
+
if (
|
|
62
|
+
isUndefined(value) ||
|
|
63
|
+
isMethod(param) ||
|
|
64
|
+
isVariant(param) ||
|
|
65
|
+
isObject(registry[param])
|
|
66
|
+
) continue
|
|
67
|
+
|
|
68
|
+
const isElement = applyParam(param, element, options)
|
|
69
|
+
if (isElement) {
|
|
70
|
+
const { hasDefine, hasContextDefine } = isElement
|
|
71
|
+
if (element[param] && !hasDefine && !hasContextDefine) {
|
|
72
|
+
const createAsync = () => create(exec(value, element), element, param, options)
|
|
73
|
+
|
|
74
|
+
if ((element.props && element.props.lazyLoad) || options.lazyLoad) {
|
|
75
|
+
window.requestAnimationFrame(() => createAsync())
|
|
76
|
+
} else createAsync()
|
|
78
77
|
}
|
|
79
78
|
}
|
|
80
79
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@domql/element",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.19",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "index.js",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"@domql/state": "latest",
|
|
32
32
|
"@domql/utils": "latest"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "94b0e44e5e5a20b0a78459b3a31eb3f7afa1c7e6",
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@babel/core": "^7.12.0"
|
|
37
37
|
}
|
package/utils/component.js
CHANGED
|
@@ -21,7 +21,7 @@ export const addAdditionalExtend = (newExtend, element) => {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
export const extendizeByKey = (element, parent, key) => {
|
|
24
|
-
const { extend, props, state, childExtend, childProps, on, if: condition } = element
|
|
24
|
+
const { tag, extend, props, state, childExtend, childProps, on, if: condition } = element
|
|
25
25
|
const hasComponentAttrs = extend || childExtend || props || state || on || condition
|
|
26
26
|
const componentKey = key.includes('_')
|
|
27
27
|
? key.split('_')[0]
|
|
@@ -31,18 +31,22 @@ export const extendizeByKey = (element, parent, key) => {
|
|
|
31
31
|
if (!hasComponentAttrs || childProps) {
|
|
32
32
|
return {
|
|
33
33
|
extend: extendKey,
|
|
34
|
+
tag,
|
|
34
35
|
props: { ...element }
|
|
35
36
|
}
|
|
36
37
|
} else if (!extend || extend === true) {
|
|
37
38
|
return {
|
|
38
39
|
...element,
|
|
40
|
+
tag,
|
|
39
41
|
extend: extendKey
|
|
40
42
|
}
|
|
41
43
|
} else if (extend) {
|
|
42
44
|
addAdditionalExtend(extendKey, element)
|
|
43
45
|
} else if (isFunction(element)) {
|
|
46
|
+
console.log(element)
|
|
44
47
|
return {
|
|
45
48
|
extend: extendKey,
|
|
49
|
+
tag,
|
|
46
50
|
props: { ...exec(element, parent) }
|
|
47
51
|
}
|
|
48
52
|
}
|