@domql/utils 3.4.11 → 3.5.1

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.
@@ -353,7 +353,20 @@ function variables(obj = {}) {
353
353
  }
354
354
  function call(fnKey, ...args) {
355
355
  const context = this.context;
356
- return (context.utils?.[fnKey] || context.functions?.[fnKey] || context.methods?.[fnKey] || context.snippets?.[fnKey])?.call(this, ...args);
356
+ const fn = context.utils?.[fnKey] || context.functions?.[fnKey] || context.methods?.[fnKey] || context.snippets?.[fnKey];
357
+ if (!fn) return;
358
+ try {
359
+ const result = fn.call(this, ...args);
360
+ if (result && typeof result.then === "function") {
361
+ result.catch((err) => {
362
+ this.error = err;
363
+ });
364
+ }
365
+ return result;
366
+ } catch (err) {
367
+ this.error = err;
368
+ if (context?.strictMode) throw err;
369
+ }
357
370
  }
358
371
  function isMethod(param, element) {
359
372
  return Boolean(import_keys.METHODS.has(param) || element?.context?.methods?.[param]);
@@ -23,9 +23,9 @@ __export(object_exports, {
23
23
  createObjectWithoutPrototype: () => createObjectWithoutPrototype,
24
24
  deepClone: () => deepClone,
25
25
  deepContains: () => deepContains,
26
- deepDestringify: () => deepDestringify,
26
+ deepDestringifyFunctions: () => deepDestringifyFunctions,
27
27
  deepMerge: () => deepMerge,
28
- deepStringify: () => deepStringify,
28
+ deepStringifyFunctions: () => deepStringifyFunctions,
29
29
  detectInfiniteLoop: () => detectInfiniteLoop,
30
30
  excludeKeysFromObject: () => excludeKeysFromObject,
31
31
  exec: () => exec,
@@ -171,7 +171,7 @@ const deepClone = (obj, options = {}) => {
171
171
  }
172
172
  return clone2;
173
173
  };
174
- const deepStringify = (obj, stringified = {}) => {
174
+ const deepStringifyFunctions = (obj, stringified = {}) => {
175
175
  if (obj.node || obj.__ref || obj.parent || obj.__element || obj.parse) {
176
176
  ;
177
177
  (obj.__element || obj.parent?.__element).warn(
@@ -186,14 +186,14 @@ const deepStringify = (obj, stringified = {}) => {
186
186
  stringified[prop] = objProp.toString();
187
187
  } else if ((0, import_types.isObject)(objProp)) {
188
188
  stringified[prop] = {};
189
- deepStringify(objProp, stringified[prop]);
189
+ deepStringifyFunctions(objProp, stringified[prop]);
190
190
  } else if ((0, import_types.isArray)(objProp)) {
191
191
  const arr = stringified[prop] = [];
192
192
  for (let i = 0; i < objProp.length; i++) {
193
193
  const v = objProp[i];
194
194
  if ((0, import_types.isObject)(v)) {
195
195
  arr[i] = {};
196
- deepStringify(v, arr[i]);
196
+ deepStringifyFunctions(v, arr[i]);
197
197
  } else if ((0, import_types.isFunction)(v)) {
198
198
  arr[i] = v.toString();
199
199
  } else {
@@ -295,7 +295,7 @@ const hasFunction = (str) => {
295
295
  if (RE_JSON_LIKE.test(trimmed) && !hasArrow) return false;
296
296
  return true;
297
297
  };
298
- const deepDestringify = (obj, destringified = {}) => {
298
+ const deepDestringifyFunctions = (obj, destringified = {}) => {
299
299
  for (const prop in obj) {
300
300
  if (!Object.prototype.hasOwnProperty.call(obj, prop)) continue;
301
301
  const objProp = obj[prop];
@@ -324,13 +324,13 @@ const deepDestringify = (obj, destringified = {}) => {
324
324
  arr.push(arrProp);
325
325
  }
326
326
  } else if ((0, import_types.isObject)(arrProp)) {
327
- arr.push(deepDestringify(arrProp));
327
+ arr.push(deepDestringifyFunctions(arrProp));
328
328
  } else {
329
329
  arr.push(arrProp);
330
330
  }
331
331
  }
332
332
  } else if ((0, import_types.isObject)(objProp)) {
333
- destringified[prop] = deepDestringify(objProp, destringified[prop]);
333
+ destringified[prop] = deepDestringifyFunctions(objProp, destringified[prop]);
334
334
  } else {
335
335
  destringified[prop] = objProp;
336
336
  }
@@ -35,18 +35,26 @@ const getOnOrPropsEvent = (param, element) => {
35
35
  };
36
36
  const applyEvent = (param, element, state, context, options) => {
37
37
  if (!(0, import_types.isFunction)(param)) return;
38
- const result = param.call(
39
- element,
40
- element,
41
- state || element.state,
42
- context || element.context,
43
- options
44
- );
45
- if (result && typeof result.then === "function") {
46
- result.catch(() => {
47
- });
38
+ try {
39
+ const result = param.call(
40
+ element,
41
+ element,
42
+ state || element.state,
43
+ context || element.context,
44
+ options
45
+ );
46
+ if (result && typeof result.then === "function") {
47
+ result.catch((err) => {
48
+ element.error = err;
49
+ console.error("[DomQL] Async event error:", err);
50
+ });
51
+ }
52
+ return result;
53
+ } catch (err) {
54
+ element.error = err;
55
+ console.error("[DomQL] Event handler error:", err);
56
+ if (element.context?.strictMode) throw err;
48
57
  }
49
- return result;
50
58
  };
51
59
  const triggerEventOn = (param, element, options) => {
52
60
  if (!element) {
@@ -60,19 +68,27 @@ const triggerEventOn = (param, element, options) => {
60
68
  };
61
69
  const applyEventUpdate = (param, updatedObj, element, state, context, options) => {
62
70
  if (!(0, import_types.isFunction)(param)) return;
63
- const result = param.call(
64
- element,
65
- updatedObj,
66
- element,
67
- state || element.state,
68
- context || element.context,
69
- options
70
- );
71
- if (result && typeof result.then === "function") {
72
- result.catch(() => {
73
- });
71
+ try {
72
+ const result = param.call(
73
+ element,
74
+ updatedObj,
75
+ element,
76
+ state || element.state,
77
+ context || element.context,
78
+ options
79
+ );
80
+ if (result && typeof result.then === "function") {
81
+ result.catch((err) => {
82
+ element.error = err;
83
+ console.error("[DomQL] Async event update error:", err);
84
+ });
85
+ }
86
+ return result;
87
+ } catch (err) {
88
+ element.error = err;
89
+ console.error("[DomQL] Event update error:", err);
90
+ if (element.context?.strictMode) throw err;
74
91
  }
75
- return result;
76
92
  };
77
93
  const triggerEventOnUpdate = (param, updatedObj, element, options) => {
78
94
  const appliedFunction = getOnOrPropsEvent(param, element);
@@ -302,7 +302,20 @@ function variables(obj = {}) {
302
302
  }
303
303
  function call(fnKey, ...args) {
304
304
  const context = this.context;
305
- return (context.utils?.[fnKey] || context.functions?.[fnKey] || context.methods?.[fnKey] || context.snippets?.[fnKey])?.call(this, ...args);
305
+ const fn = context.utils?.[fnKey] || context.functions?.[fnKey] || context.methods?.[fnKey] || context.snippets?.[fnKey];
306
+ if (!fn) return;
307
+ try {
308
+ const result = fn.call(this, ...args);
309
+ if (result && typeof result.then === "function") {
310
+ result.catch((err) => {
311
+ this.error = err;
312
+ });
313
+ }
314
+ return result;
315
+ } catch (err) {
316
+ this.error = err;
317
+ if (context?.strictMode) throw err;
318
+ }
306
319
  }
307
320
  function isMethod(param, element) {
308
321
  return Boolean(METHODS.has(param) || element?.context?.methods?.[param]);
@@ -127,7 +127,7 @@ const deepClone = (obj, options = {}) => {
127
127
  }
128
128
  return clone2;
129
129
  };
130
- const deepStringify = (obj, stringified = {}) => {
130
+ const deepStringifyFunctions = (obj, stringified = {}) => {
131
131
  if (obj.node || obj.__ref || obj.parent || obj.__element || obj.parse) {
132
132
  ;
133
133
  (obj.__element || obj.parent?.__element).warn(
@@ -142,14 +142,14 @@ const deepStringify = (obj, stringified = {}) => {
142
142
  stringified[prop] = objProp.toString();
143
143
  } else if (isObject(objProp)) {
144
144
  stringified[prop] = {};
145
- deepStringify(objProp, stringified[prop]);
145
+ deepStringifyFunctions(objProp, stringified[prop]);
146
146
  } else if (isArray(objProp)) {
147
147
  const arr = stringified[prop] = [];
148
148
  for (let i = 0; i < objProp.length; i++) {
149
149
  const v = objProp[i];
150
150
  if (isObject(v)) {
151
151
  arr[i] = {};
152
- deepStringify(v, arr[i]);
152
+ deepStringifyFunctions(v, arr[i]);
153
153
  } else if (isFunction(v)) {
154
154
  arr[i] = v.toString();
155
155
  } else {
@@ -251,7 +251,7 @@ const hasFunction = (str) => {
251
251
  if (RE_JSON_LIKE.test(trimmed) && !hasArrow) return false;
252
252
  return true;
253
253
  };
254
- const deepDestringify = (obj, destringified = {}) => {
254
+ const deepDestringifyFunctions = (obj, destringified = {}) => {
255
255
  for (const prop in obj) {
256
256
  if (!Object.prototype.hasOwnProperty.call(obj, prop)) continue;
257
257
  const objProp = obj[prop];
@@ -280,13 +280,13 @@ const deepDestringify = (obj, destringified = {}) => {
280
280
  arr.push(arrProp);
281
281
  }
282
282
  } else if (isObject(arrProp)) {
283
- arr.push(deepDestringify(arrProp));
283
+ arr.push(deepDestringifyFunctions(arrProp));
284
284
  } else {
285
285
  arr.push(arrProp);
286
286
  }
287
287
  }
288
288
  } else if (isObject(objProp)) {
289
- destringified[prop] = deepDestringify(objProp, destringified[prop]);
289
+ destringified[prop] = deepDestringifyFunctions(objProp, destringified[prop]);
290
290
  } else {
291
291
  destringified[prop] = objProp;
292
292
  }
@@ -543,9 +543,9 @@ export {
543
543
  createObjectWithoutPrototype,
544
544
  deepClone,
545
545
  deepContains,
546
- deepDestringify,
546
+ deepDestringifyFunctions,
547
547
  deepMerge,
548
- deepStringify,
548
+ deepStringifyFunctions,
549
549
  detectInfiniteLoop,
550
550
  excludeKeysFromObject,
551
551
  exec,
@@ -9,18 +9,26 @@ const getOnOrPropsEvent = (param, element) => {
9
9
  };
10
10
  const applyEvent = (param, element, state, context, options) => {
11
11
  if (!isFunction(param)) return;
12
- const result = param.call(
13
- element,
14
- element,
15
- state || element.state,
16
- context || element.context,
17
- options
18
- );
19
- if (result && typeof result.then === "function") {
20
- result.catch(() => {
21
- });
12
+ try {
13
+ const result = param.call(
14
+ element,
15
+ element,
16
+ state || element.state,
17
+ context || element.context,
18
+ options
19
+ );
20
+ if (result && typeof result.then === "function") {
21
+ result.catch((err) => {
22
+ element.error = err;
23
+ console.error("[DomQL] Async event error:", err);
24
+ });
25
+ }
26
+ return result;
27
+ } catch (err) {
28
+ element.error = err;
29
+ console.error("[DomQL] Event handler error:", err);
30
+ if (element.context?.strictMode) throw err;
22
31
  }
23
- return result;
24
32
  };
25
33
  const triggerEventOn = (param, element, options) => {
26
34
  if (!element) {
@@ -34,19 +42,27 @@ const triggerEventOn = (param, element, options) => {
34
42
  };
35
43
  const applyEventUpdate = (param, updatedObj, element, state, context, options) => {
36
44
  if (!isFunction(param)) return;
37
- const result = param.call(
38
- element,
39
- updatedObj,
40
- element,
41
- state || element.state,
42
- context || element.context,
43
- options
44
- );
45
- if (result && typeof result.then === "function") {
46
- result.catch(() => {
47
- });
45
+ try {
46
+ const result = param.call(
47
+ element,
48
+ updatedObj,
49
+ element,
50
+ state || element.state,
51
+ context || element.context,
52
+ options
53
+ );
54
+ if (result && typeof result.then === "function") {
55
+ result.catch((err) => {
56
+ element.error = err;
57
+ console.error("[DomQL] Async event update error:", err);
58
+ });
59
+ }
60
+ return result;
61
+ } catch (err) {
62
+ element.error = err;
63
+ console.error("[DomQL] Event update error:", err);
64
+ if (element.context?.strictMode) throw err;
48
65
  }
49
- return result;
50
66
  };
51
67
  const triggerEventOnUpdate = (param, updatedObj, element, options) => {
52
68
  const appliedFunction = getOnOrPropsEvent(param, element);
@@ -87,11 +87,11 @@ var DomqlUtils = (() => {
87
87
  decodeNewlines: () => decodeNewlines,
88
88
  deepClone: () => deepClone,
89
89
  deepContains: () => deepContains,
90
- deepDestringify: () => deepDestringify,
90
+ deepDestringifyFunctions: () => deepDestringifyFunctions,
91
91
  deepExtend: () => deepExtend,
92
92
  deepMerge: () => deepMerge,
93
93
  deepMergeExtends: () => deepMergeExtends,
94
- deepStringify: () => deepStringify,
94
+ deepStringifyFunctions: () => deepStringifyFunctions,
95
95
  defineSetter: () => defineSetter,
96
96
  detectInfiniteLoop: () => detectInfiniteLoop,
97
97
  document: () => document2,
@@ -829,7 +829,7 @@ var DomqlUtils = (() => {
829
829
  }
830
830
  return clone2;
831
831
  };
832
- var deepStringify = (obj, stringified = {}) => {
832
+ var deepStringifyFunctions = (obj, stringified = {}) => {
833
833
  if (obj.node || obj.__ref || obj.parent || obj.__element || obj.parse) {
834
834
  ;
835
835
  (obj.__element || obj.parent?.__element).warn(
@@ -844,14 +844,14 @@ var DomqlUtils = (() => {
844
844
  stringified[prop] = objProp.toString();
845
845
  } else if (isObject(objProp)) {
846
846
  stringified[prop] = {};
847
- deepStringify(objProp, stringified[prop]);
847
+ deepStringifyFunctions(objProp, stringified[prop]);
848
848
  } else if (isArray(objProp)) {
849
849
  const arr = stringified[prop] = [];
850
850
  for (let i = 0; i < objProp.length; i++) {
851
851
  const v = objProp[i];
852
852
  if (isObject(v)) {
853
853
  arr[i] = {};
854
- deepStringify(v, arr[i]);
854
+ deepStringifyFunctions(v, arr[i]);
855
855
  } else if (isFunction(v)) {
856
856
  arr[i] = v.toString();
857
857
  } else {
@@ -953,7 +953,7 @@ var DomqlUtils = (() => {
953
953
  if (RE_JSON_LIKE.test(trimmed) && !hasArrow) return false;
954
954
  return true;
955
955
  };
956
- var deepDestringify = (obj, destringified = {}) => {
956
+ var deepDestringifyFunctions = (obj, destringified = {}) => {
957
957
  for (const prop in obj) {
958
958
  if (!Object.prototype.hasOwnProperty.call(obj, prop)) continue;
959
959
  const objProp = obj[prop];
@@ -982,13 +982,13 @@ var DomqlUtils = (() => {
982
982
  arr.push(arrProp);
983
983
  }
984
984
  } else if (isObject(arrProp)) {
985
- arr.push(deepDestringify(arrProp));
985
+ arr.push(deepDestringifyFunctions(arrProp));
986
986
  } else {
987
987
  arr.push(arrProp);
988
988
  }
989
989
  }
990
990
  } else if (isObject(objProp)) {
991
- destringified[prop] = deepDestringify(objProp, destringified[prop]);
991
+ destringified[prop] = deepDestringifyFunctions(objProp, destringified[prop]);
992
992
  } else {
993
993
  destringified[prop] = objProp;
994
994
  }
@@ -2392,18 +2392,26 @@ var DomqlUtils = (() => {
2392
2392
  };
2393
2393
  var applyEvent = (param, element, state, context, options) => {
2394
2394
  if (!isFunction(param)) return;
2395
- const result = param.call(
2396
- element,
2397
- element,
2398
- state || element.state,
2399
- context || element.context,
2400
- options
2401
- );
2402
- if (result && typeof result.then === "function") {
2403
- result.catch(() => {
2404
- });
2395
+ try {
2396
+ const result = param.call(
2397
+ element,
2398
+ element,
2399
+ state || element.state,
2400
+ context || element.context,
2401
+ options
2402
+ );
2403
+ if (result && typeof result.then === "function") {
2404
+ result.catch((err) => {
2405
+ element.error = err;
2406
+ console.error("[DomQL] Async event error:", err);
2407
+ });
2408
+ }
2409
+ return result;
2410
+ } catch (err) {
2411
+ element.error = err;
2412
+ console.error("[DomQL] Event handler error:", err);
2413
+ if (element.context?.strictMode) throw err;
2405
2414
  }
2406
- return result;
2407
2415
  };
2408
2416
  var triggerEventOn = (param, element, options) => {
2409
2417
  if (!element) {
@@ -2417,19 +2425,27 @@ var DomqlUtils = (() => {
2417
2425
  };
2418
2426
  var applyEventUpdate = (param, updatedObj, element, state, context, options) => {
2419
2427
  if (!isFunction(param)) return;
2420
- const result = param.call(
2421
- element,
2422
- updatedObj,
2423
- element,
2424
- state || element.state,
2425
- context || element.context,
2426
- options
2427
- );
2428
- if (result && typeof result.then === "function") {
2429
- result.catch(() => {
2430
- });
2428
+ try {
2429
+ const result = param.call(
2430
+ element,
2431
+ updatedObj,
2432
+ element,
2433
+ state || element.state,
2434
+ context || element.context,
2435
+ options
2436
+ );
2437
+ if (result && typeof result.then === "function") {
2438
+ result.catch((err) => {
2439
+ element.error = err;
2440
+ console.error("[DomQL] Async event update error:", err);
2441
+ });
2442
+ }
2443
+ return result;
2444
+ } catch (err) {
2445
+ element.error = err;
2446
+ console.error("[DomQL] Event update error:", err);
2447
+ if (element.context?.strictMode) throw err;
2431
2448
  }
2432
- return result;
2433
2449
  };
2434
2450
  var triggerEventOnUpdate = (param, updatedObj, element, options) => {
2435
2451
  const appliedFunction = getOnOrPropsEvent(param, element);
@@ -2745,7 +2761,20 @@ var DomqlUtils = (() => {
2745
2761
  }
2746
2762
  function call(fnKey, ...args) {
2747
2763
  const context = this.context;
2748
- return (context.utils?.[fnKey] || context.functions?.[fnKey] || context.methods?.[fnKey] || context.snippets?.[fnKey])?.call(this, ...args);
2764
+ const fn = context.utils?.[fnKey] || context.functions?.[fnKey] || context.methods?.[fnKey] || context.snippets?.[fnKey];
2765
+ if (!fn) return;
2766
+ try {
2767
+ const result = fn.call(this, ...args);
2768
+ if (result && typeof result.then === "function") {
2769
+ result.catch((err) => {
2770
+ this.error = err;
2771
+ });
2772
+ }
2773
+ return result;
2774
+ } catch (err) {
2775
+ this.error = err;
2776
+ if (context?.strictMode) throw err;
2777
+ }
2749
2778
  }
2750
2779
  function isMethod(param, element) {
2751
2780
  return Boolean(METHODS.has(param) || element?.context?.methods?.[param]);
package/methods.js CHANGED
@@ -377,12 +377,25 @@ export function variables (obj = {}) {
377
377
  */
378
378
  export function call (fnKey, ...args) {
379
379
  const context = this.context
380
- return (
380
+ const fn = (
381
381
  context.utils?.[fnKey] ||
382
382
  context.functions?.[fnKey] ||
383
383
  context.methods?.[fnKey] ||
384
384
  context.snippets?.[fnKey]
385
- )?.call(this, ...args)
385
+ )
386
+ if (!fn) return
387
+ try {
388
+ const result = fn.call(this, ...args)
389
+ if (result && typeof result.then === 'function') {
390
+ result.catch((err) => {
391
+ this.error = err
392
+ })
393
+ }
394
+ return result
395
+ } catch (err) {
396
+ this.error = err
397
+ if (context?.strictMode) throw err
398
+ }
386
399
  }
387
400
 
388
401
  export function isMethod (param, element) {
package/object.js CHANGED
@@ -180,7 +180,7 @@ export const deepClone = (obj, options = {}) => {
180
180
  /**
181
181
  * Stringify object
182
182
  */
183
- export const deepStringify = (obj, stringified = {}) => {
183
+ export const deepStringifyFunctions = (obj, stringified = {}) => {
184
184
  if (obj.node || obj.__ref || obj.parent || obj.__element || obj.parse) {
185
185
  ;(obj.__element || obj.parent?.__element).warn(
186
186
  'Trying to clone element or state at',
@@ -195,14 +195,14 @@ export const deepStringify = (obj, stringified = {}) => {
195
195
  stringified[prop] = objProp.toString()
196
196
  } else if (isObject(objProp)) {
197
197
  stringified[prop] = {}
198
- deepStringify(objProp, stringified[prop])
198
+ deepStringifyFunctions(objProp, stringified[prop])
199
199
  } else if (isArray(objProp)) {
200
200
  const arr = stringified[prop] = []
201
201
  for (let i = 0; i < objProp.length; i++) {
202
202
  const v = objProp[i]
203
203
  if (isObject(v)) {
204
204
  arr[i] = {}
205
- deepStringify(v, arr[i])
205
+ deepStringifyFunctions(v, arr[i])
206
206
  } else if (isFunction(v)) {
207
207
  arr[i] = v.toString()
208
208
  } else {
@@ -303,7 +303,7 @@ export const hasFunction = str => {
303
303
  return true
304
304
  }
305
305
 
306
- export const deepDestringify = (obj, destringified = {}) => {
306
+ export const deepDestringifyFunctions = (obj, destringified = {}) => {
307
307
  for (const prop in obj) {
308
308
  if (!Object.prototype.hasOwnProperty.call(obj, prop)) continue
309
309
 
@@ -334,13 +334,13 @@ export const deepDestringify = (obj, destringified = {}) => {
334
334
  arr.push(arrProp)
335
335
  }
336
336
  } else if (isObject(arrProp)) {
337
- arr.push(deepDestringify(arrProp))
337
+ arr.push(deepDestringifyFunctions(arrProp))
338
338
  } else {
339
339
  arr.push(arrProp)
340
340
  }
341
341
  }
342
342
  } else if (isObject(objProp)) {
343
- destringified[prop] = deepDestringify(objProp, destringified[prop])
343
+ destringified[prop] = deepDestringifyFunctions(objProp, destringified[prop])
344
344
  } else {
345
345
  destringified[prop] = objProp
346
346
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@domql/utils",
3
- "version": "3.4.11",
3
+ "version": "3.5.1",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "module": "./dist/esm/index.js",
package/triggerEvent.js CHANGED
@@ -13,17 +13,26 @@ const getOnOrPropsEvent = (param, element) => {
13
13
 
14
14
  export const applyEvent = (param, element, state, context, options) => {
15
15
  if (!isFunction(param)) return
16
- const result = param.call(
17
- element,
18
- element,
19
- state || element.state,
20
- context || element.context,
21
- options
22
- )
23
- if (result && typeof result.then === 'function') {
24
- result.catch(() => {})
16
+ try {
17
+ const result = param.call(
18
+ element,
19
+ element,
20
+ state || element.state,
21
+ context || element.context,
22
+ options
23
+ )
24
+ if (result && typeof result.then === 'function') {
25
+ result.catch((err) => {
26
+ element.error = err
27
+ console.error('[DomQL] Async event error:', err)
28
+ })
29
+ }
30
+ return result
31
+ } catch (err) {
32
+ element.error = err
33
+ console.error('[DomQL] Event handler error:', err)
34
+ if (element.context?.strictMode) throw err
25
35
  }
26
- return result
27
36
  }
28
37
 
29
38
  export const triggerEventOn = (param, element, options) => {
@@ -46,18 +55,27 @@ export const applyEventUpdate = (
46
55
  options
47
56
  ) => {
48
57
  if (!isFunction(param)) return
49
- const result = param.call(
50
- element,
51
- updatedObj,
52
- element,
53
- state || element.state,
54
- context || element.context,
55
- options
56
- )
57
- if (result && typeof result.then === 'function') {
58
- result.catch(() => {})
58
+ try {
59
+ const result = param.call(
60
+ element,
61
+ updatedObj,
62
+ element,
63
+ state || element.state,
64
+ context || element.context,
65
+ options
66
+ )
67
+ if (result && typeof result.then === 'function') {
68
+ result.catch((err) => {
69
+ element.error = err
70
+ console.error('[DomQL] Async event update error:', err)
71
+ })
72
+ }
73
+ return result
74
+ } catch (err) {
75
+ element.error = err
76
+ console.error('[DomQL] Event update error:', err)
77
+ if (element.context?.strictMode) throw err
59
78
  }
60
- return result
61
79
  }
62
80
 
63
81
  export const triggerEventOnUpdate = (param, updatedObj, element, options) => {