@domql/element 2.5.159 → 2.5.161
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/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 +1 -1
- package/mixins/text.js +1 -1
- package/package.json +6 -6
- 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/text.js
CHANGED
|
@@ -22,7 +22,7 @@ __export(text_exports, {
|
|
|
22
22
|
text: () => text
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(text_exports);
|
|
25
|
-
var
|
|
25
|
+
var import_create = require("../create");
|
|
26
26
|
var import_utils = require("@domql/utils");
|
|
27
27
|
const text = (param, element, node) => {
|
|
28
28
|
let prop = (0, import_utils.exec)(param, element);
|
|
@@ -39,7 +39,7 @@ const text = (param, element, node) => {
|
|
|
39
39
|
if (element.__text.node)
|
|
40
40
|
element.__text.node.nodeValue = prop;
|
|
41
41
|
} else
|
|
42
|
-
(0,
|
|
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
|
package/mixins/text.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@domql/element",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.161",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "index.js",
|
|
@@ -26,12 +26,12 @@
|
|
|
26
26
|
"prepublish": "rimraf -I dist && yarn build && yarn 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.161",
|
|
30
|
+
"@domql/render": "^2.5.161",
|
|
31
|
+
"@domql/state": "^2.5.161",
|
|
32
|
+
"@domql/utils": "^2.5.161"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "39a7af3d77c6b0257d5e1a0d6110850926d83c19",
|
|
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
|
/**
|