@domql/element 2.5.115 → 2.5.117

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/dist/cjs/set.js CHANGED
@@ -66,7 +66,6 @@ const set = function(params, options = {}, el) {
66
66
  if (options.preventContentUpdate === true && !hasCollection)
67
67
  return;
68
68
  if (ref.__noCollectionDifference || __contentRef && __contentRef.__cached && (0, import_utils.deepContains)(params, content)) {
69
- console.log((0, import_utils.deepContains)(params, content));
70
69
  if (content == null ? void 0 : content.update)
71
70
  content.update();
72
71
  return;
@@ -64,19 +64,28 @@ const clone = (obj, exclude = METHODS_EXL) => {
64
64
  }
65
65
  return o;
66
66
  };
67
- const deepClone = (obj, exclude = METHODS_EXL) => {
68
- const o = (0, import_utils.isArray)(obj) ? [] : {};
69
- for (const e in obj) {
70
- if (exclude.includes(e))
71
- continue;
72
- let objProp = obj[e];
73
- if (e === "extend" && (0, import_utils.isArray)(objProp)) {
74
- objProp = mergeArray(objProp, exclude);
67
+ const deepClone = (obj, exclude = METHODS_EXL, seen = /* @__PURE__ */ new WeakMap()) => {
68
+ if (obj === null || typeof obj !== "object") {
69
+ return obj;
70
+ }
71
+ if (obj instanceof Node || obj === window || obj instanceof Document) {
72
+ return obj;
73
+ }
74
+ if (seen.has(obj)) {
75
+ return seen.get(obj);
76
+ }
77
+ const o = Array.isArray(obj) ? [] : {};
78
+ seen.set(obj, o);
79
+ for (const key in obj) {
80
+ if (Object.prototype.hasOwnProperty.call(obj, key)) {
81
+ if (exclude.includes(key))
82
+ continue;
83
+ let value = obj[key];
84
+ if (key === "extend" && Array.isArray(value)) {
85
+ value = mergeArray(value, exclude);
86
+ }
87
+ o[key] = deepClone(value, exclude, seen);
75
88
  }
76
- if ((0, import_utils.isObjectLike)(objProp)) {
77
- o[e] = deepClone(objProp, exclude);
78
- } else
79
- o[e] = objProp;
80
89
  }
81
90
  return o;
82
91
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@domql/element",
3
- "version": "2.5.115",
3
+ "version": "2.5.117",
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": "9a5b056f557d5dca04d5fd0908411a53e5bad2f2",
34
+ "gitHead": "56be344ba28e3cb51c146c1b74fe3c0e21341879",
35
35
  "devDependencies": {
36
36
  "@babel/core": "^7.12.0"
37
37
  }
package/set.js CHANGED
@@ -37,7 +37,6 @@ const set = function (params, options = {}, el) {
37
37
  if (options.preventContentUpdate === true && !hasCollection) return
38
38
 
39
39
  if (ref.__noCollectionDifference || (__contentRef && __contentRef.__cached && deepContains(params, content))) {
40
- console.log(deepContains(params, content))
41
40
  if (content?.update) content.update()
42
41
  return
43
42
  }
package/utils/object.js CHANGED
@@ -38,21 +38,60 @@ export const clone = (obj, exclude = METHODS_EXL) => {
38
38
  /**
39
39
  * Deep cloning of object
40
40
  */
41
- export const deepClone = (obj, exclude = METHODS_EXL) => {
42
- const o = isArray(obj) ? [] : {}
43
- for (const e in obj) {
44
- if (exclude.includes(e)) continue
45
- let objProp = obj[e]
46
- if (e === 'extend' && isArray(objProp)) {
47
- objProp = mergeArray(objProp, exclude)
41
+ export const deepClone = (obj, exclude = METHODS_EXL, seen = new WeakMap()) => {
42
+ // Check for null or undefined
43
+ if (obj === null || typeof obj !== 'object') {
44
+ return obj
45
+ }
46
+
47
+ // Check for DOM nodes, Window, or Document
48
+ if (obj instanceof Node || obj === window || obj instanceof Document) {
49
+ return obj
50
+ }
51
+
52
+ // Check for circular references
53
+ if (seen.has(obj)) {
54
+ return seen.get(obj)
55
+ }
56
+
57
+ // Create a new object or array
58
+ const o = Array.isArray(obj) ? [] : {}
59
+
60
+ // Store this object in our circular reference map
61
+ seen.set(obj, o)
62
+
63
+ for (const key in obj) {
64
+ if (Object.prototype.hasOwnProperty.call(obj, key)) {
65
+ if (exclude.includes(key)) continue
66
+
67
+ let value = obj[key]
68
+
69
+ if (key === 'extend' && Array.isArray(value)) {
70
+ value = mergeArray(value, exclude)
71
+ }
72
+
73
+ o[key] = deepClone(value, exclude, seen)
48
74
  }
49
- if (isObjectLike(objProp)) {
50
- o[e] = deepClone(objProp, exclude)
51
- } else o[e] = objProp
52
75
  }
76
+
53
77
  return o
54
78
  }
55
79
 
80
+ // export const deepClone = (obj, exclude = METHODS_EXL) => {
81
+ // const o = isArray(obj) ? [] : {}
82
+ // for (const e in obj) {
83
+ // if (exclude.includes(e)) continue
84
+ // let objProp = obj[e]
85
+ // if (e === 'extend' && isArray(objProp)) {
86
+ // objProp = mergeArray(objProp, exclude)
87
+ // }
88
+ // if (isObjectLike(objProp)) {
89
+ // o[e] = deepClone(objProp, exclude)
90
+ // } else o[e] = objProp
91
+ // }
92
+ // return o
93
+ // }
94
+
56
95
  /**
57
96
  * Overwrites object properties with another
58
97
  */