@domql/element 2.5.111 → 2.5.112
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/content.js +11 -10
- package/dist/cjs/props/create.js +1 -1
- package/dist/cjs/utils/object.js +2 -2
- package/mixins/content.js +9 -8
- package/package.json +2 -2
- package/props/create.js +2 -2
- package/utils/object.js +3 -3
package/create.js
CHANGED
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
isNode,
|
|
25
25
|
isUndefined,
|
|
26
26
|
generateKey,
|
|
27
|
-
|
|
27
|
+
deepCloneWithExtend
|
|
28
28
|
} from '@domql/utils'
|
|
29
29
|
|
|
30
30
|
import OPTIONS from './cache/options'
|
|
@@ -60,7 +60,7 @@ const create = (element, parent, key, options = OPTIONS.create || {}, attachOpti
|
|
|
60
60
|
const ref = addRef(element, parent, key)
|
|
61
61
|
|
|
62
62
|
// assign initial props
|
|
63
|
-
ref.__initialProps =
|
|
63
|
+
ref.__initialProps = deepCloneWithExtend(element.props, [])
|
|
64
64
|
|
|
65
65
|
// assign context
|
|
66
66
|
applyContext(element, parent, options)
|
package/dist/cjs/create.js
CHANGED
|
@@ -57,7 +57,7 @@ const create = (element, parent, key, options = import_options.default.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.deepCloneWithExtend)(element.props, []);
|
|
61
61
|
applyContext(element, parent, options);
|
|
62
62
|
(0, import_component.applyComponentFromContext)(element, parent, options);
|
|
63
63
|
if (!ref.__skipCreate) {
|
|
@@ -43,22 +43,23 @@ const updateContent = function(params, options) {
|
|
|
43
43
|
if (element.content.update)
|
|
44
44
|
element.content.update(params, options);
|
|
45
45
|
};
|
|
46
|
-
const removeContent = function(el) {
|
|
46
|
+
const removeContent = function(el, opts = {}) {
|
|
47
47
|
const element = el || this;
|
|
48
48
|
const { __ref } = element;
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
const contentElementKey = opts.contentElementKey || "content";
|
|
50
|
+
if (element[contentElementKey]) {
|
|
51
|
+
if (element[contentElementKey].node && element.node) {
|
|
52
|
+
if (element[contentElementKey].tag === "fragment")
|
|
52
53
|
element.node.innerHTML = "";
|
|
53
54
|
else
|
|
54
|
-
element.node.removeChild(element.
|
|
55
|
+
element.node.removeChild(element[contentElementKey].node);
|
|
55
56
|
}
|
|
56
57
|
const { __cached } = __ref;
|
|
57
|
-
if (__cached && __cached
|
|
58
|
-
if (__cached.
|
|
59
|
-
__cached.
|
|
60
|
-
else if (__cached
|
|
61
|
-
__cached.
|
|
58
|
+
if (__cached && __cached[contentElementKey]) {
|
|
59
|
+
if (__cached[contentElementKey].tag === "fragment")
|
|
60
|
+
__cached[contentElementKey].parent.node.innerHTML = "";
|
|
61
|
+
else if (__cached[contentElementKey] && (0, import_utils.isFunction)(__cached[contentElementKey].remove))
|
|
62
|
+
__cached[contentElementKey].remove();
|
|
62
63
|
}
|
|
63
64
|
delete element.content;
|
|
64
65
|
}
|
package/dist/cjs/props/create.js
CHANGED
|
@@ -52,7 +52,7 @@ const syncProps = (props, element) => {
|
|
|
52
52
|
const execProps = (0, import_utils.exec)(v, element);
|
|
53
53
|
element.props = (0, import_utils.deepMerge)(
|
|
54
54
|
mergedProps,
|
|
55
|
-
(0, import_utils.
|
|
55
|
+
(0, import_utils.deepCloneWithExtend)(execProps, import_ignore.IGNORE_PROPS_PARAMS),
|
|
56
56
|
import_ignore.IGNORE_PROPS_PARAMS
|
|
57
57
|
);
|
|
58
58
|
});
|
package/dist/cjs/utils/object.js
CHANGED
|
@@ -126,10 +126,10 @@ const mergeIfExisted = (a, b) => {
|
|
|
126
126
|
return a || b;
|
|
127
127
|
};
|
|
128
128
|
const mergeArray = (arr, exclude = ["parent", "node", "__element", "state", "context", "__ref"]) => {
|
|
129
|
-
return arr.reduce((a, c) => deepMerge(a,
|
|
129
|
+
return arr.reduce((a, c) => deepMerge(a, (0, import_utils.deepCloneWithExtend)(c, exclude)), {});
|
|
130
130
|
};
|
|
131
131
|
const mergeAndCloneIfArray = (obj) => {
|
|
132
|
-
return (0, import_utils.isArray)(obj) ? mergeArray(obj) :
|
|
132
|
+
return (0, import_utils.isArray)(obj) ? mergeArray(obj) : (0, import_utils.deepCloneWithExtend)(obj);
|
|
133
133
|
};
|
|
134
134
|
const flattenRecursive = (param, prop, stack = []) => {
|
|
135
135
|
const objectized = mergeAndCloneIfArray(param);
|
package/mixins/content.js
CHANGED
|
@@ -10,20 +10,21 @@ export const updateContent = function (params, options) {
|
|
|
10
10
|
if (element.content.update) element.content.update(params, options)
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
export const removeContent = function (el) {
|
|
13
|
+
export const removeContent = function (el, opts = {}) {
|
|
14
14
|
const element = el || this
|
|
15
15
|
const { __ref } = element
|
|
16
|
+
const contentElementKey = opts.contentElementKey || 'content'
|
|
16
17
|
|
|
17
|
-
if (element
|
|
18
|
-
if (element.
|
|
19
|
-
if (element.
|
|
20
|
-
else element.node.removeChild(element.
|
|
18
|
+
if (element[contentElementKey]) {
|
|
19
|
+
if (element[contentElementKey].node && element.node) {
|
|
20
|
+
if (element[contentElementKey].tag === 'fragment') element.node.innerHTML = ''
|
|
21
|
+
else element.node.removeChild(element[contentElementKey].node)
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
const { __cached } = __ref
|
|
24
|
-
if (__cached && __cached
|
|
25
|
-
if (__cached.
|
|
26
|
-
else if (__cached
|
|
25
|
+
if (__cached && __cached[contentElementKey]) {
|
|
26
|
+
if (__cached[contentElementKey].tag === 'fragment') __cached[contentElementKey].parent.node.innerHTML = ''
|
|
27
|
+
else if (__cached[contentElementKey] && isFunction(__cached[contentElementKey].remove)) __cached[contentElementKey].remove()
|
|
27
28
|
}
|
|
28
29
|
|
|
29
30
|
delete element.content
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@domql/element",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.112",
|
|
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": "8a59640e77bcd22114bdf64dfa4945604b5bfd1f",
|
|
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, deepCloneWithExtend, deepMerge } from '@domql/utils'
|
|
4
4
|
import { IGNORE_PROPS_PARAMS } from './ignore'
|
|
5
5
|
|
|
6
6
|
import { inheritParentProps } from './inherit'
|
|
@@ -36,7 +36,7 @@ export const syncProps = (props, element) => {
|
|
|
36
36
|
// it was causing infinite loop at early days
|
|
37
37
|
element.props = deepMerge(
|
|
38
38
|
mergedProps,
|
|
39
|
-
|
|
39
|
+
deepCloneWithExtend(execProps, IGNORE_PROPS_PARAMS),
|
|
40
40
|
IGNORE_PROPS_PARAMS
|
|
41
41
|
)
|
|
42
42
|
})
|
package/utils/object.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
import { isArray, isObject, isObjectLike, joinArrays } from '@domql/utils'
|
|
3
|
+
import { isArray, isObject, isObjectLike, joinArrays, deepCloneWithExtend } from '@domql/utils'
|
|
4
4
|
import { IGNORE_STATE_PARAMS } from '@domql/state'
|
|
5
5
|
import { IGNORE_PROPS_PARAMS } from '../props'
|
|
6
6
|
import { METHODS } from '../methods'
|
|
@@ -115,14 +115,14 @@ export const mergeIfExisted = (a, b) => {
|
|
|
115
115
|
* Merges array extends
|
|
116
116
|
*/
|
|
117
117
|
export const mergeArray = (arr, exclude = ['parent', 'node', '__element', 'state', 'context', '__ref']) => {
|
|
118
|
-
return arr.reduce((a, c) => deepMerge(a,
|
|
118
|
+
return arr.reduce((a, c) => deepMerge(a, deepCloneWithExtend(c, exclude)), {})
|
|
119
119
|
}
|
|
120
120
|
|
|
121
121
|
/**
|
|
122
122
|
* Merges array extends
|
|
123
123
|
*/
|
|
124
124
|
export const mergeAndCloneIfArray = obj => {
|
|
125
|
-
return isArray(obj) ? mergeArray(obj) :
|
|
125
|
+
return isArray(obj) ? mergeArray(obj) : deepCloneWithExtend(obj)
|
|
126
126
|
}
|
|
127
127
|
|
|
128
128
|
/**
|