@domql/utils 2.3.70 → 2.3.77

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.
@@ -41,9 +41,14 @@ __export(object_exports, {
41
41
  module.exports = __toCommonJS(object_exports);
42
42
  var import_globals = require("@domql/globals");
43
43
  var import_types = require("./types.js");
44
- const exec = (param, element, state) => {
45
- if ((0, import_types.isFunction)(param))
46
- return param(element, state || element.state);
44
+ const exec = (param, element, state, context) => {
45
+ if ((0, import_types.isFunction)(param)) {
46
+ return param(
47
+ element,
48
+ state || element.state,
49
+ context || element.context
50
+ );
51
+ }
47
52
  return param;
48
53
  };
49
54
  const map = (obj, extention, element) => {
@@ -166,17 +171,16 @@ const deepDestringify = (obj, stringified = {}) => {
166
171
  if (e)
167
172
  stringified[prop] = objProp;
168
173
  }
174
+ } else {
175
+ stringified[prop] = objProp;
169
176
  }
170
- } else {
171
- stringified[prop] = objProp;
172
- }
173
- if ((0, import_types.isArray)(objProp)) {
177
+ } else if ((0, import_types.isArray)(objProp)) {
174
178
  stringified[prop] = [];
175
179
  objProp.forEach((arrProp) => {
176
180
  if ((0, import_types.isString)(arrProp)) {
177
181
  if (arrProp.includes("=>") || arrProp.includes("function") || arrProp.startsWith("(")) {
178
182
  try {
179
- const evalProp = import_globals.window.eval(arrProp);
183
+ const evalProp = import_globals.window.eval(`(${arrProp})`);
180
184
  stringified[prop].push(evalProp);
181
185
  } catch (e) {
182
186
  if (e)
@@ -185,12 +189,16 @@ const deepDestringify = (obj, stringified = {}) => {
185
189
  } else {
186
190
  stringified[prop].push(arrProp);
187
191
  }
188
- } else {
192
+ } else if ((0, import_types.isObject)(arrProp)) {
189
193
  stringified[prop].push(deepDestringify(arrProp));
194
+ } else {
195
+ stringified[prop].push(arrProp);
190
196
  }
191
197
  });
192
198
  } else if ((0, import_types.isObject)(objProp)) {
193
199
  stringified[prop] = deepDestringify(objProp, stringified[prop]);
200
+ } else {
201
+ stringified[prop] = objProp;
194
202
  }
195
203
  }
196
204
  return stringified;
package/object.js CHANGED
@@ -1,10 +1,16 @@
1
1
  'use strict'
2
2
 
3
3
  import { window } from '@domql/globals'
4
- import { isFunction, isObjectLike, isObject, isArray, isString } from './types.js'
5
-
6
- export const exec = (param, element, state) => {
7
- if (isFunction(param)) return param(element, state || element.state)
4
+ import { isFunction, isObjectLike, isObject, isArray, isString, is } from './types.js'
5
+
6
+ export const exec = (param, element, state, context) => {
7
+ if (isFunction(param)) {
8
+ return param(
9
+ element,
10
+ state || element.state,
11
+ context || element.context
12
+ )
13
+ }
8
14
  return param
9
15
  }
10
16
 
@@ -144,29 +150,31 @@ export const deepDestringify = (obj, stringified = {}) => {
144
150
  const evalProp = window.eval(`(${objProp})`) // use parentheses to convert string to function expression
145
151
  stringified[prop] = evalProp
146
152
  } catch (e) { if (e) stringified[prop] = objProp }
153
+ } else {
154
+ stringified[prop] = objProp
147
155
  }
148
- } else {
149
- stringified[prop] = objProp
150
- }
151
-
152
- if (isArray(objProp)) {
156
+ } else if (isArray(objProp)) {
153
157
  stringified[prop] = []
154
158
  objProp.forEach((arrProp) => {
155
159
  if (isString(arrProp)) {
156
160
  if (arrProp.includes('=>') || arrProp.includes('function') || arrProp.startsWith('(')) {
157
161
  try {
158
- const evalProp = window.eval(arrProp) // eslint-disable-line
162
+ const evalProp = window.eval(`(${arrProp})`) // use parentheses to convert string to function expression
159
163
  stringified[prop].push(evalProp)
160
164
  } catch (e) { if (e) stringified[prop].push(arrProp) }
161
165
  } else {
162
166
  stringified[prop].push(arrProp)
163
167
  }
164
- } else {
168
+ } else if (isObject(arrProp)) {
165
169
  stringified[prop].push(deepDestringify(arrProp))
170
+ } else {
171
+ stringified[prop].push(arrProp)
166
172
  }
167
173
  })
168
174
  } else if (isObject(objProp)) {
169
175
  stringified[prop] = deepDestringify(objProp, stringified[prop]) // recursively call deepDestringify for nested objects
176
+ } else {
177
+ stringified[prop] = objProp
170
178
  }
171
179
  }
172
180
  return stringified
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@domql/utils",
3
- "version": "2.3.70",
3
+ "version": "2.3.77",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "module": "index.js",
@@ -22,5 +22,5 @@
22
22
  "@domql/globals": "latest",
23
23
  "@domql/tags": "latest"
24
24
  },
25
- "gitHead": "c2fa4c40d134093b837eafc1c4374561032281bf"
25
+ "gitHead": "eb59a416c2b22ef1cea1b6da0064805f8843a8de"
26
26
  }