@domql/element 2.5.160 → 2.5.162
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 -2
- package/dist/cjs/create.js +1 -1
- package/dist/cjs/methods/index.js +1 -1
- package/dist/cjs/mixins/attr.js +6 -6
- package/dist/cjs/mixins/classList.js +2 -2
- package/dist/cjs/mixins/content.js +2 -2
- package/dist/cjs/mixins/data.js +2 -2
- package/dist/cjs/mixins/html.js +2 -2
- package/dist/cjs/mixins/scope.js +2 -2
- package/dist/cjs/mixins/state.js +2 -2
- package/dist/cjs/mixins/style.js +2 -2
- package/dist/cjs/mixins/text.js +2 -2
- package/dist/cjs/props/create.js +1 -1
- package/dist/cjs/update.js +1 -1
- package/dist/cjs/utils/extendUtils.js +1 -1
- package/dist/cjs/utils/object.js +2 -28
- package/methods/index.js +2 -2
- package/mixins/attr.js +4 -4
- package/mixins/classList.js +1 -1
- package/mixins/content.js +1 -1
- package/mixins/data.js +1 -1
- package/mixins/html.js +1 -1
- package/mixins/scope.js +1 -1
- package/mixins/state.js +1 -1
- package/mixins/style.js +1 -1
- package/mixins/text.js +1 -1
- package/package.json +8 -8
- package/props/create.js +2 -2
- package/update.js +4 -3
- package/utils/extendUtils.js +2 -2
- package/utils/object.js +3 -45
package/create.js
CHANGED
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
isUndefined,
|
|
15
15
|
generateKey,
|
|
16
16
|
checkIfKeyIsComponent,
|
|
17
|
-
|
|
17
|
+
deepClone,
|
|
18
18
|
applyComponentFromContext,
|
|
19
19
|
applyKeyComponentAsExtend,
|
|
20
20
|
isVariant,
|
|
@@ -60,7 +60,7 @@ export const create = (element, parent, key, options = OPTIONS.create || {}, att
|
|
|
60
60
|
|
|
61
61
|
const ref = addRef(element, parent, key)
|
|
62
62
|
|
|
63
|
-
ref.__initialProps =
|
|
63
|
+
ref.__initialProps = deepClone(element.props)
|
|
64
64
|
|
|
65
65
|
applyContext(element, parent, options)
|
|
66
66
|
|
package/dist/cjs/create.js
CHANGED
|
@@ -57,7 +57,7 @@ const create = (element, parent, key, options = import_options.OPTIONS.create ||
|
|
|
57
57
|
parent = redefineParent(element, parent, key);
|
|
58
58
|
key = createKey(element, parent, key);
|
|
59
59
|
const ref = addRef(element, parent, key);
|
|
60
|
-
ref.__initialProps = (0, import_utils.
|
|
60
|
+
ref.__initialProps = (0, import_utils.deepClone)(element.props);
|
|
61
61
|
applyContext(element, parent, options);
|
|
62
62
|
(0, import_utils.applyComponentFromContext)(element, parent, options);
|
|
63
63
|
if (!ref.__skipCreate) {
|
package/dist/cjs/mixins/attr.js
CHANGED
|
@@ -25,14 +25,14 @@ 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");
|
|
28
|
-
|
|
29
|
-
const { __ref } = element;
|
|
30
|
-
const { __attr } =
|
|
28
|
+
function attr(params, element, node) {
|
|
29
|
+
const { __ref: ref, props } = element;
|
|
30
|
+
const { __attr } = ref;
|
|
31
31
|
if ((0, import_utils.isNot)("object"))
|
|
32
32
|
(0, import_report.report)("HTMLInvalidAttr", params);
|
|
33
33
|
if (params) {
|
|
34
|
-
if (
|
|
35
|
-
(0, import_utils2.deepMerge)(params,
|
|
34
|
+
if (props.attr)
|
|
35
|
+
(0, import_utils2.deepMerge)(params, props.attr);
|
|
36
36
|
for (const attr2 in params) {
|
|
37
37
|
const val = (0, import_utils.exec)(params[attr2], element);
|
|
38
38
|
if (val !== false && !(0, import_utils.isUndefined)(val) && !(0, import_utils.isNull)(val) && node.setAttribute)
|
|
@@ -42,5 +42,5 @@ const attr = (params, element, node) => {
|
|
|
42
42
|
__attr[attr2] = val;
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
|
-
}
|
|
45
|
+
}
|
|
46
46
|
var attr_default = attr;
|
|
@@ -69,7 +69,7 @@ const applyClassListOnNode = (params, element, node) => {
|
|
|
69
69
|
node.classList = className;
|
|
70
70
|
return className;
|
|
71
71
|
};
|
|
72
|
-
|
|
72
|
+
function applyClasslist(params, element, node) {
|
|
73
73
|
applyClassListOnNode(params, element, node);
|
|
74
|
-
}
|
|
74
|
+
}
|
|
75
75
|
var classList_default = applyClasslist;
|
|
@@ -61,7 +61,7 @@ const removeContent = function(el, opts = {}) {
|
|
|
61
61
|
delete element[contentElementKey];
|
|
62
62
|
}
|
|
63
63
|
};
|
|
64
|
-
|
|
64
|
+
function setContent(param, element, node, opts) {
|
|
65
65
|
const contentElementKey = (0, import_utils.setContentKey)(element, opts);
|
|
66
66
|
if (param && element) {
|
|
67
67
|
if (element[contentElementKey].update) {
|
|
@@ -70,5 +70,5 @@ const setContent = (param, element, node, opts) => {
|
|
|
70
70
|
import_set.set.call(element, param, opts);
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
|
-
}
|
|
73
|
+
}
|
|
74
74
|
var content_default = setContent;
|
package/dist/cjs/mixins/data.js
CHANGED
|
@@ -24,7 +24,7 @@ __export(data_exports, {
|
|
|
24
24
|
module.exports = __toCommonJS(data_exports);
|
|
25
25
|
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
29
|
if (element.props.data)
|
|
30
30
|
(0, import_utils.deepMerge)(params, element.props.data);
|
|
@@ -38,5 +38,5 @@ const data = (params, element, node) => {
|
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
|
-
}
|
|
41
|
+
}
|
|
42
42
|
var data_default = data;
|
package/dist/cjs/mixins/html.js
CHANGED
|
@@ -23,7 +23,7 @@ __export(html_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(html_exports);
|
|
25
25
|
var import_utils = require("@domql/utils");
|
|
26
|
-
|
|
26
|
+
function html(param, element, node) {
|
|
27
27
|
var _a;
|
|
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;
|
|
@@ -34,5 +34,5 @@ const html = (param, element, node) => {
|
|
|
34
34
|
node.innerHTML = prop;
|
|
35
35
|
__ref.__html = prop;
|
|
36
36
|
}
|
|
37
|
-
}
|
|
37
|
+
}
|
|
38
38
|
var html_default = html;
|
package/dist/cjs/mixins/scope.js
CHANGED
|
@@ -23,7 +23,7 @@ __export(scope_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(scope_exports);
|
|
25
25
|
var import_utils = require("@domql/utils");
|
|
26
|
-
|
|
26
|
+
function scope(params, element, node) {
|
|
27
27
|
if (!(0, import_utils.isObject)(params))
|
|
28
28
|
return;
|
|
29
29
|
for (const scopeItem in params) {
|
|
@@ -34,5 +34,5 @@ const scope = (params, element, node) => {
|
|
|
34
34
|
element.scope[scopeItem] = value;
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
|
-
}
|
|
37
|
+
}
|
|
38
38
|
var scope_default = scope;
|
package/dist/cjs/mixins/state.js
CHANGED
|
@@ -24,7 +24,7 @@ __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
|
-
|
|
27
|
+
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) {
|
|
@@ -35,5 +35,5 @@ const state = (params, element, node) => {
|
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
return element;
|
|
38
|
-
}
|
|
38
|
+
}
|
|
39
39
|
var state_default = state;
|
package/dist/cjs/mixins/style.js
CHANGED
|
@@ -24,12 +24,12 @@ __export(style_exports, {
|
|
|
24
24
|
module.exports = __toCommonJS(style_exports);
|
|
25
25
|
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
29
|
if ((0, import_utils.isObject)(params))
|
|
30
30
|
(0, import_utils.map)(node.style, params, element);
|
|
31
31
|
else
|
|
32
32
|
(0, import_report.report)("HTMLInvalidStyles", params);
|
|
33
33
|
}
|
|
34
|
-
}
|
|
34
|
+
}
|
|
35
35
|
var style_default = style;
|
package/dist/cjs/mixins/text.js
CHANGED
|
@@ -24,7 +24,7 @@ __export(text_exports, {
|
|
|
24
24
|
module.exports = __toCommonJS(text_exports);
|
|
25
25
|
var import_create = require("../create");
|
|
26
26
|
var import_utils = require("@domql/utils");
|
|
27
|
-
|
|
27
|
+
function text(param, element, node) {
|
|
28
28
|
let prop = (0, import_utils.exec)(param, element);
|
|
29
29
|
if ((0, import_utils.isString)(prop) && prop.includes("{{")) {
|
|
30
30
|
prop = (0, import_utils.replaceLiteralsWithObjectFields)(prop, element.state);
|
|
@@ -41,5 +41,5 @@ const text = (param, element, node) => {
|
|
|
41
41
|
} else
|
|
42
42
|
(0, import_create.create)({ tag: "string", text: prop }, element, "__text");
|
|
43
43
|
}
|
|
44
|
-
}
|
|
44
|
+
}
|
|
45
45
|
var text_default = text;
|
package/dist/cjs/props/create.js
CHANGED
|
@@ -57,7 +57,7 @@ const syncProps = (props, element, opts) => {
|
|
|
57
57
|
}
|
|
58
58
|
element.props = (0, import_utils.deepMerge)(
|
|
59
59
|
mergedProps,
|
|
60
|
-
(0, import_utils.
|
|
60
|
+
(0, import_utils.deepClone)(execProps, { ignore: import_ignore.IGNORE_PROPS_PARAMS }),
|
|
61
61
|
import_ignore.IGNORE_PROPS_PARAMS
|
|
62
62
|
);
|
|
63
63
|
});
|
package/dist/cjs/update.js
CHANGED
|
@@ -46,7 +46,7 @@ const UPDATE_DEFAULT_OPTIONS = {
|
|
|
46
46
|
};
|
|
47
47
|
const update = function(params = {}, opts) {
|
|
48
48
|
const calleeElementCache = opts == null ? void 0 : opts.calleeElement;
|
|
49
|
-
const options = (0,
|
|
49
|
+
const options = (0, import_utils.deepClone)((0, import_utils.isObject)(opts) ? (0, import_utils2.deepMerge)(opts, UPDATE_DEFAULT_OPTIONS) : UPDATE_DEFAULT_OPTIONS, { exclude: ["calleeElement"] });
|
|
50
50
|
options.calleeElement = calleeElementCache;
|
|
51
51
|
const element = this;
|
|
52
52
|
const { parent, node, key } = element;
|
|
@@ -103,7 +103,7 @@ const deepMergeExtend = (element, extend) => {
|
|
|
103
103
|
};
|
|
104
104
|
const cloneAndMergeArrayExtend = (stack) => {
|
|
105
105
|
return stack.reduce((a, c) => {
|
|
106
|
-
return deepMergeExtend(a, (0, import_utils.
|
|
106
|
+
return deepMergeExtend(a, (0, import_utils.deepClone)(c));
|
|
107
107
|
}, {});
|
|
108
108
|
};
|
|
109
109
|
const fallbackStringExtend = (extend, context, options = {}) => {
|
package/dist/cjs/utils/object.js
CHANGED
|
@@ -21,7 +21,6 @@ __export(object_exports, {
|
|
|
21
21
|
METHODS: () => METHODS,
|
|
22
22
|
METHODS_EXL: () => METHODS_EXL,
|
|
23
23
|
clone: () => clone,
|
|
24
|
-
deepClone: () => deepClone,
|
|
25
24
|
deepMerge: () => deepMerge,
|
|
26
25
|
flattenRecursive: () => flattenRecursive,
|
|
27
26
|
mergeAndCloneIfArray: () => mergeAndCloneIfArray,
|
|
@@ -113,31 +112,6 @@ const clone = (obj, exclude = METHODS_EXL) => {
|
|
|
113
112
|
}
|
|
114
113
|
return o;
|
|
115
114
|
};
|
|
116
|
-
const deepClone = (obj, exclude = METHODS_EXL, seen = /* @__PURE__ */ new WeakMap()) => {
|
|
117
|
-
if (obj === null || typeof obj !== "object") {
|
|
118
|
-
return obj;
|
|
119
|
-
}
|
|
120
|
-
if (obj instanceof window.Node || obj === window || obj instanceof window.Document) {
|
|
121
|
-
return obj;
|
|
122
|
-
}
|
|
123
|
-
if (seen.has(obj)) {
|
|
124
|
-
return seen.get(obj);
|
|
125
|
-
}
|
|
126
|
-
const o = Array.isArray(obj) ? [] : {};
|
|
127
|
-
seen.set(obj, o);
|
|
128
|
-
for (const key in obj) {
|
|
129
|
-
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
130
|
-
if (exclude.includes(key))
|
|
131
|
-
continue;
|
|
132
|
-
let value = obj[key];
|
|
133
|
-
if (key === "extend" && Array.isArray(value)) {
|
|
134
|
-
value = mergeArray(value, exclude);
|
|
135
|
-
}
|
|
136
|
-
o[key] = deepClone(value, exclude, seen);
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
return o;
|
|
140
|
-
};
|
|
141
115
|
const overwrite = (element, params, options) => {
|
|
142
116
|
const changes = {};
|
|
143
117
|
const { __ref } = element;
|
|
@@ -184,10 +158,10 @@ const mergeIfExisted = (a, b) => {
|
|
|
184
158
|
return a || b;
|
|
185
159
|
};
|
|
186
160
|
const mergeArray = (arr, exclude = ["parent", "node", "__element", "state", "context", "__ref"]) => {
|
|
187
|
-
return arr.reduce((a, c) => deepMerge(a, (0, import_utils.
|
|
161
|
+
return arr.reduce((a, c) => deepMerge(a, (0, import_utils.deepClone)(c, { exclude })), {});
|
|
188
162
|
};
|
|
189
163
|
const mergeAndCloneIfArray = (obj) => {
|
|
190
|
-
return (0, import_utils.isArray)(obj) ? mergeArray(obj) : (0, import_utils.
|
|
164
|
+
return (0, import_utils.isArray)(obj) ? mergeArray(obj) : (0, import_utils.deepClone)(obj);
|
|
191
165
|
};
|
|
192
166
|
const flattenRecursive = (param, prop, stack = []) => {
|
|
193
167
|
const objectized = mergeAndCloneIfArray(param);
|
package/methods/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { isDefined, isObject, isFunction, isObjectLike, isProduction, removeValueFromArray, deepClone } from '@domql/utils'
|
|
4
4
|
import { TREE } from '../tree'
|
|
5
|
-
import { parseFilters, REGISTRY
|
|
5
|
+
import { parseFilters, REGISTRY } from '../mixins'
|
|
6
6
|
const ENV = process.env.NODE_ENV
|
|
7
7
|
|
|
8
8
|
// TODO: update these files
|
|
@@ -216,7 +216,7 @@ export function error (...params) {
|
|
|
216
216
|
if (ENV === 'test' || ENV === 'development') {
|
|
217
217
|
if (params[params.length - 1]?.debugger) debugger // eslint-disable-line
|
|
218
218
|
console.error(...params)
|
|
219
|
-
if (params[params.length - 1]?.verbose)
|
|
219
|
+
if (params[params.length - 1]?.verbose) verbose.call(this)
|
|
220
220
|
}
|
|
221
221
|
}
|
|
222
222
|
|
package/mixins/attr.js
CHANGED
|
@@ -7,12 +7,12 @@ import { deepMerge } from '../utils'
|
|
|
7
7
|
/**
|
|
8
8
|
* Recursively add attributes to a DOM node
|
|
9
9
|
*/
|
|
10
|
-
export
|
|
11
|
-
const { __ref } = element
|
|
12
|
-
const { __attr } =
|
|
10
|
+
export function attr (params, element, node) {
|
|
11
|
+
const { __ref: ref, props } = element
|
|
12
|
+
const { __attr } = ref
|
|
13
13
|
if (isNot('object')) report('HTMLInvalidAttr', params)
|
|
14
14
|
if (params) {
|
|
15
|
-
if (
|
|
15
|
+
if (props.attr) deepMerge(params, props.attr)
|
|
16
16
|
for (const attr in params) {
|
|
17
17
|
const val = exec(params[attr], element)
|
|
18
18
|
// if (__attr[attr] === val) return
|
package/mixins/classList.js
CHANGED
|
@@ -43,7 +43,7 @@ export const applyClassListOnNode = (params, element, node) => {
|
|
|
43
43
|
return className
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
export
|
|
46
|
+
export function applyClasslist (params, element, node) {
|
|
47
47
|
applyClassListOnNode(params, element, node)
|
|
48
48
|
}
|
|
49
49
|
|
package/mixins/content.js
CHANGED
|
@@ -41,7 +41,7 @@ export const removeContent = function (el, opts = {}) {
|
|
|
41
41
|
* Appends anything as content
|
|
42
42
|
* an original one as a child
|
|
43
43
|
*/
|
|
44
|
-
export
|
|
44
|
+
export function setContent (param, element, node, opts) {
|
|
45
45
|
const contentElementKey = setContentKey(element, opts)
|
|
46
46
|
if (param && element) {
|
|
47
47
|
if (element[contentElementKey].update) {
|
package/mixins/data.js
CHANGED
|
@@ -7,7 +7,7 @@ import { report } from '@domql/report'
|
|
|
7
7
|
* Apply data parameters on the DOM nodes
|
|
8
8
|
* this should only work if `showOnNode: true` is passed
|
|
9
9
|
*/
|
|
10
|
-
export
|
|
10
|
+
export function data (params, element, node) {
|
|
11
11
|
if (params) {
|
|
12
12
|
if (element.props.data) deepMerge(params, element.props.data)
|
|
13
13
|
if (params.showOnNode) {
|
package/mixins/html.js
CHANGED
|
@@ -6,7 +6,7 @@ import { exec } from '@domql/utils'
|
|
|
6
6
|
* Appends raw HTML as content
|
|
7
7
|
* an original one as a child
|
|
8
8
|
*/
|
|
9
|
-
export
|
|
9
|
+
export function html (param, element, node) {
|
|
10
10
|
const prop = exec(param, element) || exec(element?.props?.html, element)
|
|
11
11
|
const { __ref } = element
|
|
12
12
|
if (prop !== __ref.__html) {
|
package/mixins/scope.js
CHANGED
|
@@ -6,7 +6,7 @@ import { isFunction, isObject } from '@domql/utils'
|
|
|
6
6
|
* Apply data parameters on the DOM nodes
|
|
7
7
|
* this should only work if `showOnNode: true` is passed
|
|
8
8
|
*/
|
|
9
|
-
export
|
|
9
|
+
export function scope (params, element, node) {
|
|
10
10
|
if (!isObject(params)) return
|
|
11
11
|
|
|
12
12
|
// Apply data params on node
|
package/mixins/state.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { IGNORE_STATE_PARAMS } from '@domql/state'
|
|
4
4
|
import { exec, isObject } from '@domql/utils'
|
|
5
5
|
|
|
6
|
-
export
|
|
6
|
+
export function state (params, element, node) {
|
|
7
7
|
const state = exec(params, element)
|
|
8
8
|
|
|
9
9
|
if (isObject(state)) {
|
package/mixins/style.js
CHANGED
|
@@ -6,7 +6,7 @@ import { report } from '@domql/report'
|
|
|
6
6
|
/**
|
|
7
7
|
* Recursively add styles to a DOM node
|
|
8
8
|
*/
|
|
9
|
-
export
|
|
9
|
+
export function style (params, element, node) {
|
|
10
10
|
if (params) {
|
|
11
11
|
if (isObject(params)) map(node.style, params, element)
|
|
12
12
|
else report('HTMLInvalidStyles', params)
|
package/mixins/text.js
CHANGED
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
* Creates a text node and appends into
|
|
12
12
|
* an original one as a child
|
|
13
13
|
*/
|
|
14
|
-
export
|
|
14
|
+
export function text (param, element, node) {
|
|
15
15
|
let prop = exec(param, element)
|
|
16
16
|
if (isString(prop) && prop.includes('{{')) {
|
|
17
17
|
prop = replaceLiteralsWithObjectFields(prop, element.state)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@domql/element",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.162",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "index.js",
|
|
@@ -22,16 +22,16 @@
|
|
|
22
22
|
"copy:package:cjs": "cp ../../build/package-cjs.json dist/cjs/package.json",
|
|
23
23
|
"build:esm": "npx esbuild *.js **/*.js --target=es2019 --format=esm --outdir=dist/esm",
|
|
24
24
|
"build:cjs": "npx esbuild *.js **/*.js --target=node16 --format=cjs --outdir=dist/cjs",
|
|
25
|
-
"build": "
|
|
26
|
-
"prepublish": "rimraf -I dist &&
|
|
25
|
+
"build": "npm run build:cjs",
|
|
26
|
+
"prepublish": "rimraf -I dist && npm run build && npm run copy:package:cjs"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@domql/event": "^2.5.
|
|
30
|
-
"@domql/render": "^2.5.
|
|
31
|
-
"@domql/state": "^2.5.
|
|
32
|
-
"@domql/utils": "^2.5.
|
|
29
|
+
"@domql/event": "^2.5.162",
|
|
30
|
+
"@domql/render": "^2.5.162",
|
|
31
|
+
"@domql/state": "^2.5.162",
|
|
32
|
+
"@domql/utils": "^2.5.162"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "0aeb25f284d863a57821a0a74937c2b9babb7969",
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@babel/core": "^7.12.0"
|
|
37
37
|
}
|
package/props/create.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
import { exec, isArray, isObject,
|
|
3
|
+
import { exec, isArray, isObject, deepClone, deepMerge } from '@domql/utils'
|
|
4
4
|
import { IGNORE_PROPS_PARAMS } from './ignore'
|
|
5
5
|
|
|
6
6
|
import { inheritParentProps } from './inherit'
|
|
@@ -39,7 +39,7 @@ export const syncProps = (props, element, opts) => {
|
|
|
39
39
|
// it was causing infinite loop at early days
|
|
40
40
|
element.props = deepMerge(
|
|
41
41
|
mergedProps,
|
|
42
|
-
|
|
42
|
+
deepClone(execProps, { ignore: IGNORE_PROPS_PARAMS }),
|
|
43
43
|
IGNORE_PROPS_PARAMS
|
|
44
44
|
)
|
|
45
45
|
})
|
package/update.js
CHANGED
|
@@ -12,7 +12,8 @@ import {
|
|
|
12
12
|
merge,
|
|
13
13
|
isVariant,
|
|
14
14
|
overwriteDeep,
|
|
15
|
-
createSnapshotId
|
|
15
|
+
createSnapshotId,
|
|
16
|
+
deepClone
|
|
16
17
|
} from '@domql/utils'
|
|
17
18
|
|
|
18
19
|
import { applyEvent, triggerEventOn, triggerEventOnUpdate } from '@domql/event'
|
|
@@ -25,7 +26,7 @@ import { throughExecProps, throughUpdatedDefine, throughUpdatedExec } from './it
|
|
|
25
26
|
import { REGISTRY } from './mixins'
|
|
26
27
|
import { applyParam } from './utils/applyParam'
|
|
27
28
|
import { OPTIONS } from './cache/options'
|
|
28
|
-
import { METHODS_EXL,
|
|
29
|
+
import { METHODS_EXL, deepMerge } from './utils' // old utils (current)
|
|
29
30
|
|
|
30
31
|
const snapshot = {
|
|
31
32
|
snapshotId: createSnapshotId
|
|
@@ -42,7 +43,7 @@ const UPDATE_DEFAULT_OPTIONS = {
|
|
|
42
43
|
|
|
43
44
|
export const update = function (params = {}, opts) {
|
|
44
45
|
const calleeElementCache = opts?.calleeElement
|
|
45
|
-
const options = deepClone(isObject(opts) ? deepMerge(opts, UPDATE_DEFAULT_OPTIONS) : UPDATE_DEFAULT_OPTIONS, ['calleeElement'])
|
|
46
|
+
const options = deepClone(isObject(opts) ? deepMerge(opts, UPDATE_DEFAULT_OPTIONS) : UPDATE_DEFAULT_OPTIONS, { exclude: ['calleeElement'] })
|
|
46
47
|
options.calleeElement = calleeElementCache
|
|
47
48
|
const element = this
|
|
48
49
|
const { parent, node, key } = element
|
package/utils/extendUtils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
import { isArray, isFunction, isObject, isString,
|
|
3
|
+
import { isArray, isFunction, isObject, isString, deepClone } from '@domql/utils'
|
|
4
4
|
const ENV = process.env.NODE_ENV
|
|
5
5
|
|
|
6
6
|
export const generateHash = () => Math.random().toString(36).substring(2)
|
|
@@ -71,7 +71,7 @@ export const deepMergeExtend = (element, extend) => {
|
|
|
71
71
|
|
|
72
72
|
export const cloneAndMergeArrayExtend = stack => {
|
|
73
73
|
return stack.reduce((a, c) => {
|
|
74
|
-
return deepMergeExtend(a,
|
|
74
|
+
return deepMergeExtend(a, deepClone(c))
|
|
75
75
|
}, {})
|
|
76
76
|
}
|
|
77
77
|
|
package/utils/object.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
import { isArray, isObject, isObjectLike, joinArrays,
|
|
3
|
+
import { isArray, isObject, isObjectLike, joinArrays, deepClone } from '@domql/utils'
|
|
4
4
|
import { IGNORE_PROPS_PARAMS } from '../props'
|
|
5
5
|
|
|
6
6
|
// breaks server build
|
|
@@ -68,48 +68,6 @@ export const clone = (obj, exclude = METHODS_EXL) => {
|
|
|
68
68
|
return o
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
/**
|
|
72
|
-
* Deep cloning of object
|
|
73
|
-
*/
|
|
74
|
-
export const deepClone = (obj, exclude = METHODS_EXL, seen = new WeakMap()) => {
|
|
75
|
-
// Check for null or undefined
|
|
76
|
-
if (obj === null || typeof obj !== 'object') {
|
|
77
|
-
return obj
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// Check for DOM nodes, Window, or Document
|
|
81
|
-
if (obj instanceof window.Node || obj === window || obj instanceof window.Document) {
|
|
82
|
-
return obj
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
// Check for circular references
|
|
86
|
-
if (seen.has(obj)) {
|
|
87
|
-
return seen.get(obj)
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
// Create a new object or array
|
|
91
|
-
const o = Array.isArray(obj) ? [] : {}
|
|
92
|
-
|
|
93
|
-
// Store this object in our circular reference map
|
|
94
|
-
seen.set(obj, o)
|
|
95
|
-
|
|
96
|
-
for (const key in obj) {
|
|
97
|
-
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
98
|
-
if (exclude.includes(key)) continue
|
|
99
|
-
|
|
100
|
-
let value = obj[key]
|
|
101
|
-
|
|
102
|
-
if (key === 'extend' && Array.isArray(value)) {
|
|
103
|
-
value = mergeArray(value, exclude)
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
o[key] = deepClone(value, exclude, seen)
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
return o
|
|
111
|
-
}
|
|
112
|
-
|
|
113
71
|
// export const deepClone = (obj, exclude = METHODS_EXL) => {
|
|
114
72
|
// const o = isArray(obj) ? [] : {}
|
|
115
73
|
// for (const e in obj) {
|
|
@@ -187,14 +145,14 @@ export const mergeIfExisted = (a, b) => {
|
|
|
187
145
|
* Merges array extends
|
|
188
146
|
*/
|
|
189
147
|
export const mergeArray = (arr, exclude = ['parent', 'node', '__element', 'state', 'context', '__ref']) => {
|
|
190
|
-
return arr.reduce((a, c) => deepMerge(a,
|
|
148
|
+
return arr.reduce((a, c) => deepMerge(a, deepClone(c, { exclude })), {})
|
|
191
149
|
}
|
|
192
150
|
|
|
193
151
|
/**
|
|
194
152
|
* Merges array extends
|
|
195
153
|
*/
|
|
196
154
|
export const mergeAndCloneIfArray = obj => {
|
|
197
|
-
return isArray(obj) ? mergeArray(obj) :
|
|
155
|
+
return isArray(obj) ? mergeArray(obj) : deepClone(obj)
|
|
198
156
|
}
|
|
199
157
|
|
|
200
158
|
/**
|