@domql/utils 2.28.54 → 2.28.55

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.
@@ -145,13 +145,14 @@ const deepClone = (obj, options = {}) => {
145
145
  visited = /* @__PURE__ */ new WeakMap(),
146
146
  handleExtend = false
147
147
  } = options;
148
+ const contentWindow = targetWindow || import_globals.window || globalThis;
148
149
  if (!(0, import_types.isObjectLike)(obj) || (0, import_node.isDOMNode)(obj)) {
149
150
  return obj;
150
151
  }
151
152
  if (visited.has(obj)) {
152
153
  return visited.get(obj);
153
154
  }
154
- const clone2 = targetWindow ? (0, import_types.isArray)(obj) ? new targetWindow.Array() : new targetWindow.Object() : (0, import_types.isArray)(obj) ? [] : {};
155
+ const clone2 = contentWindow ? (0, import_types.isArray)(obj) ? new contentWindow.Array() : new contentWindow.Object() : (0, import_types.isArray)(obj) ? [] : {};
155
156
  visited.set(obj, clone2);
156
157
  for (const key in obj) {
157
158
  if (!Object.prototype.hasOwnProperty.call(obj, key)) continue;
@@ -168,8 +169,8 @@ const deepClone = (obj, options = {}) => {
168
169
  clone2[key] = (0, import_array.mergeArray)(value, exclude);
169
170
  continue;
170
171
  }
171
- if ((0, import_types.isFunction)(value) && targetWindow) {
172
- clone2[key] = targetWindow.eval("(" + value.toString() + ")");
172
+ if ((0, import_types.isFunction)(value) && contentWindow) {
173
+ clone2[key] = contentWindow.eval("(" + value.toString() + ")");
173
174
  continue;
174
175
  }
175
176
  if ((0, import_types.isObjectLike)(value)) {
@@ -114,13 +114,14 @@ const deepClone = (obj, options = {}) => {
114
114
  visited = /* @__PURE__ */ new WeakMap(),
115
115
  handleExtend = false
116
116
  } = options;
117
+ const contentWindow = targetWindow || window || globalThis;
117
118
  if (!isObjectLike(obj) || isDOMNode(obj)) {
118
119
  return obj;
119
120
  }
120
121
  if (visited.has(obj)) {
121
122
  return visited.get(obj);
122
123
  }
123
- const clone2 = targetWindow ? isArray(obj) ? new targetWindow.Array() : new targetWindow.Object() : isArray(obj) ? [] : {};
124
+ const clone2 = contentWindow ? isArray(obj) ? new contentWindow.Array() : new contentWindow.Object() : isArray(obj) ? [] : {};
124
125
  visited.set(obj, clone2);
125
126
  for (const key in obj) {
126
127
  if (!Object.prototype.hasOwnProperty.call(obj, key)) continue;
@@ -137,8 +138,8 @@ const deepClone = (obj, options = {}) => {
137
138
  clone2[key] = mergeArray(value, exclude);
138
139
  continue;
139
140
  }
140
- if (isFunction(value) && targetWindow) {
141
- clone2[key] = targetWindow.eval("(" + value.toString() + ")");
141
+ if (isFunction(value) && contentWindow) {
142
+ clone2[key] = contentWindow.eval("(" + value.toString() + ")");
142
143
  continue;
143
144
  }
144
145
  if (isObjectLike(value)) {
package/object.js CHANGED
@@ -135,6 +135,8 @@ export const deepClone = (obj, options = {}) => {
135
135
  handleExtend = false
136
136
  } = options
137
137
 
138
+ const contentWindow = targetWindow || window || globalThis
139
+
138
140
  // Handle non-object types and special cases
139
141
  if (!isObjectLike(obj) || isDOMNode(obj)) {
140
142
  return obj
@@ -146,10 +148,10 @@ export const deepClone = (obj, options = {}) => {
146
148
  }
147
149
 
148
150
  // Create appropriate container based on type and window context
149
- const clone = targetWindow
151
+ const clone = contentWindow
150
152
  ? isArray(obj)
151
- ? new targetWindow.Array()
152
- : new targetWindow.Object()
153
+ ? new contentWindow.Array()
154
+ : new contentWindow.Object()
153
155
  : isArray(obj)
154
156
  ? []
155
157
  : {}
@@ -184,8 +186,8 @@ export const deepClone = (obj, options = {}) => {
184
186
  }
185
187
 
186
188
  // Handle functions in cross-frame scenario
187
- if (isFunction(value) && targetWindow) {
188
- clone[key] = targetWindow.eval('(' + value.toString() + ')')
189
+ if (isFunction(value) && contentWindow) {
190
+ clone[key] = contentWindow.eval('(' + value.toString() + ')')
189
191
  continue
190
192
  }
191
193
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@domql/utils",
3
- "version": "2.28.54",
3
+ "version": "2.28.55",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "module": "index.js",
@@ -24,8 +24,8 @@
24
24
  "build": "npx rimraf -I dist; npm run build:cjs; npm run build:esm",
25
25
  "prepublish": "npm run build; npm run copy:package:cjs"
26
26
  },
27
- "gitHead": "947717d4d20d1ca8c1b66c6f823a767b4843020a",
27
+ "gitHead": "b961a4a9ce4d20b91b493a263cf33cec689fa195",
28
28
  "devDependencies": {
29
- "@babel/core": "^7.26.0"
29
+ "@babel/core": "^7.27.1"
30
30
  }
31
31
  }