@domql/utils 3.1.2 → 3.2.7

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.
Files changed (59) hide show
  1. package/array.js +11 -5
  2. package/cache.js +3 -0
  3. package/component.js +3 -4
  4. package/dist/cjs/array.js +11 -5
  5. package/dist/cjs/component.js +4 -6
  6. package/dist/cjs/element.js +6 -6
  7. package/dist/cjs/env.js +1 -1
  8. package/dist/cjs/events.js +3 -3
  9. package/dist/cjs/extends.js +44 -28
  10. package/dist/cjs/function.js +3 -3
  11. package/dist/cjs/index.js +1 -0
  12. package/dist/cjs/key.js +2 -2
  13. package/dist/cjs/keys.js +29 -15
  14. package/dist/cjs/methods.js +88 -33
  15. package/dist/cjs/object.js +154 -141
  16. package/dist/cjs/props.js +43 -34
  17. package/dist/cjs/scope.js +1 -2
  18. package/dist/cjs/state.js +12 -11
  19. package/dist/cjs/string.js +15 -20
  20. package/dist/cjs/tags.js +71 -16
  21. package/dist/cjs/triggerEvent.js +90 -0
  22. package/dist/cjs/types.js +4 -12
  23. package/dist/esm/array.js +11 -5
  24. package/dist/esm/component.js +4 -6
  25. package/dist/esm/element.js +9 -27
  26. package/dist/esm/env.js +1 -1
  27. package/dist/esm/events.js +3 -3
  28. package/dist/esm/extends.js +48 -50
  29. package/dist/esm/function.js +3 -3
  30. package/dist/esm/index.js +1 -0
  31. package/dist/esm/key.js +2 -2
  32. package/dist/esm/keys.js +29 -15
  33. package/dist/esm/methods.js +86 -31
  34. package/dist/esm/object.js +158 -165
  35. package/dist/esm/props.js +43 -50
  36. package/dist/esm/scope.js +1 -2
  37. package/dist/esm/state.js +21 -38
  38. package/dist/esm/string.js +15 -20
  39. package/dist/esm/tags.js +71 -16
  40. package/dist/esm/triggerEvent.js +70 -0
  41. package/dist/esm/types.js +4 -12
  42. package/dist/iife/index.js +2779 -0
  43. package/element.js +2 -2
  44. package/events.js +3 -3
  45. package/extends.js +28 -17
  46. package/function.js +10 -9
  47. package/index.js +1 -0
  48. package/keys.js +25 -15
  49. package/log.js +0 -1
  50. package/methods.js +99 -24
  51. package/object.js +155 -215
  52. package/package.json +34 -13
  53. package/props.js +44 -27
  54. package/state.js +12 -12
  55. package/string.js +20 -38
  56. package/tags.js +45 -16
  57. package/triggerEvent.js +76 -0
  58. package/types.js +8 -25
  59. package/dist/cjs/package.json +0 -4
package/element.js CHANGED
@@ -12,7 +12,7 @@ const ENV = process.env.NODE_ENV
12
12
  export const returnValueAsText = (element, parent, key) => {
13
13
  const childExtendsTag = parent.childExtends && parent.childExtends.tag
14
14
  const childPropsTag = parent.props.childProps && parent.props.childProps.tag
15
- const isKeyValidHTMLTag = HTML_TAGS.body.indexOf(key) > -1 && key
15
+ const isKeyValidHTMLTag = HTML_TAGS.body.has(key) && key
16
16
  return {
17
17
  text: element,
18
18
  tag: childExtendsTag || childPropsTag || isKeyValidHTMLTag || 'string'
@@ -26,7 +26,7 @@ export const createBasedOnType = (element, parent, key) => {
26
26
  console.warn(
27
27
  key,
28
28
  'element is undefined in',
29
- parent && parent.__ref && parent.__ref.path
29
+ parent?.__ref?.path
30
30
  )
31
31
  }
32
32
  return {}
package/events.js CHANGED
@@ -9,9 +9,9 @@ export function addEventFromProps (key, obj) {
9
9
  const origEvent = on[eventName]
10
10
  const funcFromProps = props[key]
11
11
  if (isFunction(origEvent)) {
12
- on[eventName] = async (...args) => {
13
- const originalEventRetunrs = await origEvent(...args)
14
- if (originalEventRetunrs !== false) await funcFromProps(...args)
12
+ on[eventName] = (...args) => {
13
+ const originalEventRetunrs = origEvent(...args)
14
+ if (originalEventRetunrs !== false) funcFromProps(...args)
15
15
  }
16
16
  } else on[eventName] = funcFromProps
17
17
  }
package/extends.js CHANGED
@@ -94,7 +94,7 @@ export const setHashedExtend = (extend, stack) => {
94
94
  if (!isString(extend)) {
95
95
  extend.__hash = hash
96
96
  }
97
- if (!['__proto__', 'constructor', 'prototype'].includes(hash)) {
97
+ if (hash !== '__proto__' && hash !== 'constructor' && hash !== 'prototype') {
98
98
  extendStackRegistry[hash] = stack
99
99
  }
100
100
  return stack
@@ -125,11 +125,14 @@ export const extractArrayExtend = (
125
125
  }
126
126
 
127
127
  export const deepExtend = (extend, stack, context, processed = new Set()) => {
128
- const extendOflattenExtend = extend.extends
129
- // Remove extends property before adding to stack
128
+ const extendOflattenExtend = extend.extends || extend.extend
129
+ // Remove extends/extend properties before adding to stack
130
130
  const cleanExtend = { ...extend }
131
131
  delete cleanExtend.extends
132
- if (Object.keys(cleanExtend).length > 0) {
132
+ delete cleanExtend.extend
133
+ let hasKeys = false
134
+ for (const _k in cleanExtend) { hasKeys = true; break } // eslint-disable-line
135
+ if (hasKeys) {
133
136
  stack.push(cleanExtend)
134
137
  }
135
138
  if (extendOflattenExtend) {
@@ -157,7 +160,7 @@ export const flattenExtend = (
157
160
 
158
161
  processed.add(extend)
159
162
 
160
- if (extend?.extends) {
163
+ if (extend?.extends || extend?.extend) {
161
164
  deepExtend(extend, stack, context, processed)
162
165
  } else if (extend) {
163
166
  stack.push(extend)
@@ -166,12 +169,16 @@ export const flattenExtend = (
166
169
  return stack
167
170
  }
168
171
 
172
+ const MERGE_EXTENDS_SKIP = new Set([
173
+ 'parent', 'node', '__ref', '__proto__', 'extend', 'childExtend', 'childExtendRecursive'
174
+ ])
175
+
169
176
  export const deepMergeExtends = (element, extend) => {
170
177
  // Clone extend to prevent mutations
171
178
  extend = deepClone(extend)
172
179
 
173
180
  for (const e in extend) {
174
- if (['parent', 'node', '__ref', '__proto__'].indexOf(e) > -1) continue
181
+ if (MERGE_EXTENDS_SKIP.has(e)) continue
175
182
 
176
183
  const elementProp = element[e]
177
184
  const extendProp = extend[e]
@@ -182,7 +189,7 @@ export const deepMergeExtends = (element, extend) => {
182
189
  // Handle only properties that exist in the extend object
183
190
  if (
184
191
  Object.prototype.hasOwnProperty.call(extend, e) &&
185
- !['__proto__', 'constructor', 'prototype'].includes(e)
192
+ e !== '__proto__' && e !== 'constructor' && e !== 'prototype'
186
193
  ) {
187
194
  if (elementProp === undefined) {
188
195
  // For undefined properties in element, copy from extend
@@ -233,15 +240,15 @@ export const mapStringsWithContextComponents = (
233
240
  options = {},
234
241
  variant
235
242
  ) => {
236
- const COMPONENTS = (context && context.components) || options.components
237
- const PAGES = (context && context.pages) || options.pages
243
+ const COMPONENTS = context?.components || options.components
244
+ const PAGES = context?.pages || options.pages
238
245
  if (isString(extend)) {
239
246
  const componentExists =
240
247
  COMPONENTS &&
241
248
  (COMPONENTS[extend + '.' + variant] ||
242
249
  COMPONENTS[extend] ||
243
250
  COMPONENTS['smbls.' + extend])
244
- const pageExists = PAGES && extend.startsWith('/') && PAGES[extend]
251
+ const pageExists = PAGES && extend.charCodeAt(0) === 47 && PAGES[extend]
245
252
  if (componentExists) return componentExists
246
253
  else if (pageExists) return pageExists
247
254
  else {
@@ -283,7 +290,7 @@ export const getExtendsInElement = obj => {
283
290
 
284
291
  function traverse (o) {
285
292
  for (const key in o) {
286
- if (Object.hasOwnProperty.call(o, key)) {
293
+ if (Object.prototype.hasOwnProperty.call(o, key)) {
287
294
  // Check if the key starts with a capital letter and exclude keys like @mobileL, $propsCollection
288
295
  if (matchesComponentNaming(key)) {
289
296
  result.push(key)
@@ -316,7 +323,10 @@ export const createElementExtends = (element, parent, options = {}) => {
316
323
  const context = element.context || parent.context
317
324
  const variant = element.props?.variant
318
325
 
319
- // Add the extends property from element if it exists
326
+ // Add the extends property from element if it exists (supports v2 `extend` fallback)
327
+ if (element.extend && !element.extends) element.extends = element.extend
328
+ delete element.extend
329
+ if (!element.extends && element.props?.extends) element.extends = element.props.extends
320
330
  if (element.extends) {
321
331
  if (Array.isArray(element.extends) && element.extends.length > 0) {
322
332
  // Handle first item in array specially for variant
@@ -379,16 +389,18 @@ export const inheritChildExtends = (element, parent, options = {}) => {
379
389
  const ignoreChildExtends =
380
390
  options.ignoreChildExtends || props?.ignoreChildExtends
381
391
 
382
- if (!ignoreChildExtends && parent.childExtends) {
383
- // Use else if to avoid double-adding
384
- addExtends(parent.childExtends, element)
392
+ // Supports v2 `childExtend` fallback
393
+ const childExtends = parent.childExtends || parent.childExtend
394
+ if (!ignoreChildExtends && childExtends) {
395
+ addExtends(childExtends, element)
385
396
  }
386
397
  return ref.__extends
387
398
  }
388
399
 
389
400
  export const inheritRecursiveChildExtends = (element, parent, options = {}) => {
390
401
  const { props, __ref: ref } = element
391
- const childExtendsRecursive = parent.childExtendsRecursive
402
+ // Supports v2 `childExtendRecursive` fallback
403
+ const childExtendsRecursive = parent.childExtendsRecursive || parent.childExtendRecursive
392
404
  const ignoreChildExtendsRecursive =
393
405
  options.ignoreChildExtendsRecursive || props?.ignoreChildExtendsRecursive
394
406
  const isText = element.key === '__text'
@@ -402,7 +414,6 @@ export const createExtendsStack = (element, parent, options = {}) => {
402
414
  const { props, __ref: ref } = element
403
415
  const context = element.context || parent.context
404
416
 
405
- // if (ENV !== 'test' && ENV !== 'development') delete element.extends
406
417
  const variant = element.variant || props?.variant
407
418
 
408
419
  const __extends = removeDuplicatesInArray(
package/function.js CHANGED
@@ -16,7 +16,8 @@
16
16
  export function debounce (func, wait, immediate) {
17
17
  let timeout
18
18
  return function () {
19
- const context = this; const args = arguments
19
+ const context = this
20
+ const args = arguments
20
21
  const later = function () {
21
22
  timeout = null
22
23
  if (!immediate) func.apply(context, args)
@@ -46,11 +47,13 @@ export const debounceOnContext = (element, func, timeout = 300) => {
46
47
  let timer
47
48
  return (...args) => {
48
49
  clearTimeout(timer)
49
- timer = setTimeout(() => { func.apply(element, args) }, timeout)
50
+ timer = setTimeout(() => {
51
+ func.apply(element, args)
52
+ }, timeout)
50
53
  }
51
54
  }
52
55
 
53
- export const memoize = (fn) => {
56
+ export const memoize = fn => {
54
57
  const cache = {}
55
58
  return (...args) => {
56
59
  const n = args[0]
@@ -64,12 +67,10 @@ export const memoize = (fn) => {
64
67
  }
65
68
  }
66
69
 
67
- export const isStringFunction = inputString => {
68
- // Regular expression to match both regular and arrow function declarations
69
- const functionRegex = /^((function\s*\([^)]*\)\s*\{[^}]*\})|(\([^)]*\)\s*=>))/
70
+ const RE_STRING_FUNCTION = /^((function\s*\([^)]*\)\s*\{[^}]*\})|(\([^)]*\)\s*=>))/
70
71
 
71
- // Use the regex to test if the inputString matches the function pattern
72
- return functionRegex.test(inputString)
72
+ export const isStringFunction = inputString => {
73
+ return RE_STRING_FUNCTION.test(inputString)
73
74
  }
74
75
 
75
76
  export function cloneFunction (fn, win = window) {
@@ -79,7 +80,7 @@ export function cloneFunction (fn, win = window) {
79
80
 
80
81
  // Copy properties from original function
81
82
  for (const key in fn) {
82
- if (Object.hasOwnProperty.call(fn, key)) {
83
+ if (Object.prototype.hasOwnProperty.call(fn, key)) {
83
84
  temp[key] = fn[key]
84
85
  }
85
86
  }
package/index.js CHANGED
@@ -23,3 +23,4 @@ export * from './scope.js'
23
23
  export * from './methods.js'
24
24
  export * from './cache.js'
25
25
  export * from './update.js'
26
+ export * from './triggerEvent.js'
package/keys.js CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict'
2
2
 
3
- export const DOMQ_PROPERTIES = [
3
+ export const DOMQ_PROPERTIES = new Set([
4
4
  'attr',
5
5
  'style',
6
6
  'text',
@@ -10,12 +10,16 @@ export const DOMQ_PROPERTIES = [
10
10
  'classlist',
11
11
  'state',
12
12
  'scope',
13
+ 'root',
13
14
  'deps',
15
+ 'extend',
14
16
  'extends',
15
17
  '$router',
16
18
  'routes',
17
19
  'children',
20
+ 'childExtend',
18
21
  'childExtends',
22
+ 'childExtendRecursive',
19
23
  'childExtendsRecursive',
20
24
  'props',
21
25
  'if',
@@ -33,9 +37,9 @@ export const DOMQ_PROPERTIES = [
33
37
  'on',
34
38
  'component',
35
39
  'context'
36
- ]
40
+ ])
37
41
 
38
- export const PARSED_DOMQ_PROPERTIES = [
42
+ export const PARSED_DOMQ_PROPERTIES = new Set([
39
43
  'attr',
40
44
  'style',
41
45
  'text',
@@ -53,7 +57,7 @@ export const PARSED_DOMQ_PROPERTIES = [
53
57
  'query',
54
58
  'on',
55
59
  'context'
56
- ]
60
+ ])
57
61
 
58
62
  export const STATE_PROPERTIES = [
59
63
  'ref',
@@ -65,7 +69,7 @@ export const STATE_PROPERTIES = [
65
69
  'root'
66
70
  ]
67
71
 
68
- export const STATE_METHODS = [
72
+ export const STATE_METHODS = new Set([
69
73
  'update',
70
74
  'parse',
71
75
  'clean',
@@ -98,11 +102,11 @@ export const STATE_METHODS = [
98
102
  'removeByPath',
99
103
  'removePathCollection',
100
104
  'getByPath'
101
- ]
105
+ ])
102
106
 
103
- export const PROPS_METHODS = ['update', '__element']
107
+ export const PROPS_METHODS = new Set(['update', '__element'])
104
108
 
105
- export const METHODS = [
109
+ export const METHODS = new Set([
106
110
  'set',
107
111
  'reset',
108
112
  'update',
@@ -128,17 +132,23 @@ export const METHODS = [
128
132
  'error',
129
133
  'call',
130
134
  'nextElement',
131
- 'previousElement'
132
- ]
135
+ 'previousElement',
136
+ 'getRootState',
137
+ 'getRoot',
138
+ 'getRootData',
139
+ 'getRootContext',
140
+ 'getContext',
141
+ 'getChildren'
142
+ ])
133
143
 
134
- export const METHODS_EXL = [
135
- ...['node', 'context', 'extends', '__element', '__ref'],
144
+ export const METHODS_EXL = new Set([
145
+ 'node', 'context', 'extends', '__element', '__ref',
136
146
  ...METHODS,
137
147
  ...STATE_METHODS,
138
148
  ...PROPS_METHODS
139
- ]
149
+ ])
140
150
 
141
- export const DOMQL_EVENTS = [
151
+ export const DOMQL_EVENTS = new Set([
142
152
  'init',
143
153
  'beforeClassAssign',
144
154
  'render',
@@ -154,4 +164,4 @@ export const DOMQL_EVENTS = [
154
164
  'complete',
155
165
  'frame',
156
166
  'update'
157
- ]
167
+ ])
package/log.js CHANGED
@@ -3,7 +3,6 @@
3
3
  export const logIf = (bool, ...arg) => {
4
4
  if (bool) arg.map(v => console.log(v))
5
5
  }
6
-
7
6
  export const logGroupIf = (bool, key, ...arg) => {
8
7
  if (bool) {
9
8
  console.group(key)
package/methods.js CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict'
2
2
 
3
- import { triggerEventOn } from '@domql/event'
3
+ import { triggerEventOn } from './triggerEvent.js'
4
4
  import { DOMQ_PROPERTIES, METHODS, PARSED_DOMQ_PROPERTIES } from './keys.js'
5
5
  import { isDefined, isFunction, isObject, isObjectLike } from './types.js'
6
6
  import { deepClone } from './object.js'
@@ -55,7 +55,9 @@ export function lookup (param) {
55
55
  export function lookdown (param) {
56
56
  const el = this
57
57
  const { __ref: ref } = el
58
- const children = ref.__children
58
+ const children = ref?.__children
59
+
60
+ if (!children) return
59
61
 
60
62
  for (let i = 0; i < children.length; i++) {
61
63
  const v = children[i]
@@ -76,7 +78,9 @@ export function lookdown (param) {
76
78
  export function lookdownAll (param, results = []) {
77
79
  const el = this
78
80
  const { __ref: ref } = el
79
- const children = ref.__children
81
+ const children = ref?.__children
82
+
83
+ if (!children) return
80
84
 
81
85
  for (let i = 0; i < children.length; i++) {
82
86
  const v = children[i]
@@ -138,19 +142,67 @@ export function setProps (param, options) {
138
142
  return element
139
143
  }
140
144
 
141
- export function getRef () {
145
+ export function getRef (key) {
146
+ if (key) return this.__ref && this.__ref[key]
142
147
  return this.__ref
143
148
  }
144
149
 
150
+ export function getChildren () {
151
+ const __children = this.getRef('__children')
152
+ return __children.map(k => this[k])
153
+ }
154
+
145
155
  export function getPath () {
146
156
  return this.getRef().path
147
157
  }
148
158
 
149
- // export function set () {
150
- // }
159
+ export function getRootState (param) {
160
+ let state = null
161
+ const hasRootState = (obj) => obj.__element && obj.root?.isRootState
162
+ if (!this) {
163
+ state = window.platformState || window.smblsApp?.state
164
+ } else if (hasRootState(this)) {
165
+ state = this.root
166
+ } else if (this.__ref && this.__ref.path) {
167
+ const hasPlatformState = this.state && hasRootState(this.state)
168
+ const hasPlatformStateOnParent =
169
+ isFunction(this.state) &&
170
+ this.parent.state &&
171
+ hasRootState(this.parent.state)
172
+ if (hasPlatformState || hasPlatformStateOnParent) {
173
+ state = this.state.root || this.parent.state.root
174
+ }
175
+ }
176
+ if (!state) {
177
+ state = window.platformState || window.smblsApp?.state
178
+ }
179
+ return param ? state?.[param] : state
180
+ }
151
181
 
152
- // export function update () {
153
- // }
182
+ export function getRoot (key) {
183
+ const rootElem = this.getRootState()?.__element
184
+ return rootElem && Object.keys(rootElem).length > 0 && key
185
+ ? rootElem[key]
186
+ : rootElem
187
+ }
188
+
189
+ export function getRootData (key) {
190
+ return this.getRoot('data') &&
191
+ Object.keys(this.getRoot('data')).length > 0 &&
192
+ key
193
+ ? this.getRoot('data')[key]
194
+ : this.getRoot('data')
195
+ }
196
+
197
+ export function getRootContext (key) {
198
+ const ctx = this.getRoot()?.context
199
+ return key ? ctx[key] : ctx
200
+ }
201
+
202
+ export function getContext (key) {
203
+ const ctx = this.context
204
+ return key ? ctx[key] : ctx
205
+ }
154
206
 
155
207
  export const defineSetter = (element, key, get, set) =>
156
208
  Object.defineProperty(element, key, { get, set })
@@ -160,10 +212,10 @@ export function keys () {
160
212
  const keys = []
161
213
  for (const param in element) {
162
214
  if (
163
- // (REGISTRY[param] && !DOMQ_PROPERTIES.includes(param)) ||
164
- !Object.hasOwnProperty.call(element, param) ||
165
- (DOMQ_PROPERTIES.includes(param) &&
166
- !PARSED_DOMQ_PROPERTIES.includes(param))
215
+ // (REGISTRY[param] && !DOMQ_PROPERTIES.has(param)) ||
216
+ !Object.prototype.hasOwnProperty.call(element, param) ||
217
+ (DOMQ_PROPERTIES.has(param) &&
218
+ !PARSED_DOMQ_PROPERTIES.has(param))
167
219
  ) {
168
220
  continue
169
221
  }
@@ -174,35 +226,49 @@ export function keys () {
174
226
 
175
227
  export function parse (excl = []) {
176
228
  const element = this
177
- const { __ref: ref } = element
178
229
  const obj = {}
179
230
  const keyList = keys.call(element)
180
- keyList.forEach(v => {
181
- if (excl.includes(v)) return
231
+ const hasChildren = keyList.includes('children')
232
+ const exclSet = excl.length ? new Set(excl) : null
233
+ for (let i = 0; i < keyList.length; i++) {
234
+ const v = keyList[i]
235
+ if ((exclSet && exclSet.has(v)) || !Object.prototype.hasOwnProperty.call(element, v)) continue
236
+ if (hasChildren && v === 'content') continue
182
237
  const val = element[v]
183
238
  if (v === 'state') {
184
- if (!ref?.__hasRootState) return
239
+ if (element.__ref && !element.__ref.__hasRootState) continue
185
240
  const parsedVal = isFunction(val && val.parse) ? val.parse() : val
186
241
  obj[v] = isFunction(parsedVal)
187
242
  ? parsedVal
188
243
  : JSON.parse(JSON.stringify(parsedVal || {}))
189
244
  } else if (v === 'scope') {
190
- if (!ref?.__hasRootScope) return
245
+ if (element.__ref && !element.__ref.__hasRootScope) continue
191
246
  obj[v] = JSON.parse(JSON.stringify(val || {}))
192
- } else if (isDefined(val) && Object.hasOwnProperty.call(element, v)) {
247
+ } else if (v === 'props') {
248
+ const { __element, update, ...props } = element[v]
249
+ obj[v] = props
250
+ } else if (isDefined(val) && Object.prototype.hasOwnProperty.call(element, v)) {
193
251
  obj[v] = val
194
252
  }
195
- })
253
+ }
196
254
  return obj
197
255
  }
198
256
 
199
- export function parseDeep (excl = []) {
257
+ export function parseDeep (excl = [], visited = new WeakSet()) {
200
258
  const element = this
259
+ if (visited.has(element)) return undefined
260
+ visited.add(element)
201
261
  const obj = parse.call(element, excl)
262
+ const exclSet = excl.length ? new Set(excl) : null
202
263
  for (const v in obj) {
203
- if (excl.includes(v)) return
204
- if (isObjectLike(obj[v])) {
205
- obj[v] = parseDeep.call(obj[v], excl)
264
+ if ((exclSet && exclSet.has(v)) || !Object.prototype.hasOwnProperty.call(element, v)) continue
265
+ const val = obj[v]
266
+ if (Array.isArray(val)) {
267
+ obj[v] = val.map(item =>
268
+ isObjectLike(item) ? parseDeep.call(item, excl, visited) : item
269
+ )
270
+ } else if (isObjectLike(val)) {
271
+ obj[v] = parseDeep.call(val, excl, visited)
206
272
  }
207
273
  }
208
274
  return obj
@@ -300,6 +366,15 @@ export function variables (obj = {}) {
300
366
  }
301
367
  }
302
368
 
369
+ /**
370
+ * A unified call function that detects the calling context and adapts accordingly.
371
+ * - When called in an async context (with await), it fully resolves promises
372
+ * - When called in a sync context, it returns sync results directly and handles promises appropriately
373
+ *
374
+ * @param {string} fnKey - The name of the function to call
375
+ * @param {...any} args - Arguments to pass to the function
376
+ * @returns {any|Promise} - The result or a Promise to the result
377
+ */
303
378
  export function call (fnKey, ...args) {
304
379
  const context = this.context
305
380
  return (
@@ -311,5 +386,5 @@ export function call (fnKey, ...args) {
311
386
  }
312
387
 
313
388
  export function isMethod (param, element) {
314
- return Boolean(METHODS.includes(param) || element?.context?.methods?.[param])
389
+ return Boolean(METHODS.has(param) || element?.context?.methods?.[param])
315
390
  }