@domql/utils 2.28.54 → 2.28.56
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/object.js +4 -3
- package/dist/esm/object.js +4 -3
- package/object.js +7 -5
- package/package.json +3 -3
package/dist/cjs/object.js
CHANGED
|
@@ -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 =
|
|
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) &&
|
|
172
|
-
clone2[key] =
|
|
172
|
+
if ((0, import_types.isFunction)(value) && options.window) {
|
|
173
|
+
clone2[key] = contentWindow.eval("(" + value.toString() + ")");
|
|
173
174
|
continue;
|
|
174
175
|
}
|
|
175
176
|
if ((0, import_types.isObjectLike)(value)) {
|
package/dist/esm/object.js
CHANGED
|
@@ -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 =
|
|
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) &&
|
|
141
|
-
clone2[key] =
|
|
141
|
+
if (isFunction(value) && options.window) {
|
|
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 =
|
|
151
|
+
const clone = contentWindow
|
|
150
152
|
? isArray(obj)
|
|
151
|
-
? new
|
|
152
|
-
: new
|
|
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) &&
|
|
188
|
-
clone[key] =
|
|
189
|
+
if (isFunction(value) && options.window) {
|
|
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.
|
|
3
|
+
"version": "2.28.56",
|
|
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": "
|
|
27
|
+
"gitHead": "b70ae48a0599b6ae8b5f691c82f27ca0b860a3c6",
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@babel/core": "^7.
|
|
29
|
+
"@babel/core": "^7.27.1"
|
|
30
30
|
}
|
|
31
31
|
}
|