@domql/element 2.5.160 → 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 CHANGED
@@ -14,7 +14,7 @@ import {
14
14
  isUndefined,
15
15
  generateKey,
16
16
  checkIfKeyIsComponent,
17
- deepCloneWithExtend,
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 = deepCloneWithExtend(element.props, [])
63
+ ref.__initialProps = deepClone(element.props)
64
64
 
65
65
  applyContext(element, parent, options)
66
66
 
@@ -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.deepCloneWithExtend)(element.props, []);
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) {
@@ -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.deepCloneWithExtend)(execProps, import_ignore.IGNORE_PROPS_PARAMS),
60
+ (0, import_utils.deepClone)(execProps, { ignore: import_ignore.IGNORE_PROPS_PARAMS }),
61
61
  import_ignore.IGNORE_PROPS_PARAMS
62
62
  );
63
63
  });
@@ -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, import_utils2.deepClone)((0, import_utils.isObject)(opts) ? (0, import_utils2.deepMerge)(opts, UPDATE_DEFAULT_OPTIONS) : UPDATE_DEFAULT_OPTIONS, ["calleeElement"]);
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.deepCloneWithExtend)(c));
106
+ return deepMergeExtend(a, (0, import_utils.deepClone)(c));
107
107
  }, {});
108
108
  };
109
109
  const fallbackStringExtend = (extend, context, options = {}) => {
@@ -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.deepCloneWithExtend)(c, exclude)), {});
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.deepCloneWithExtend)(obj);
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, registry } from '../mixins'
5
+ import { parseFilters, REGISTRY } from '../mixins'
6
6
  const ENV = process.env.NODE_ENV
7
7
 
8
8
  // TODO: update these files
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@domql/element",
3
- "version": "2.5.160",
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.159",
30
- "@domql/render": "^2.5.159",
31
- "@domql/state": "^2.5.159",
32
- "@domql/utils": "^2.5.159"
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": "ab896b123edd1ec6d30fd01d28bd1a0ef4db735c",
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, deepCloneWithExtend, deepMerge } from '@domql/utils'
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
- deepCloneWithExtend(execProps, IGNORE_PROPS_PARAMS),
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, deepClone, deepMerge } from './utils' // old utils (current)
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
@@ -1,6 +1,6 @@
1
1
  'use strict'
2
2
 
3
- import { isArray, isFunction, isObject, isString, deepCloneWithExtend } from '@domql/utils'
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, deepCloneWithExtend(c))
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, deepCloneWithExtend } from '@domql/utils'
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, deepCloneWithExtend(c, exclude)), {})
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) : deepCloneWithExtend(obj)
155
+ return isArray(obj) ? mergeArray(obj) : deepClone(obj)
198
156
  }
199
157
 
200
158
  /**