@domql/event 3.1.1 → 3.2.3

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/on.js CHANGED
@@ -33,29 +33,34 @@ const getOnOrPropsEvent = (param, element) => {
33
33
  const onPropEvent = (_b = element.props) == null ? void 0 : _b["on" + param.slice(0, 1).toUpperCase() + param.slice(1)];
34
34
  return onEvent || onPropEvent;
35
35
  };
36
- const applyEvent = async (param, element, state, context, options) => {
36
+ const applyEvent = (param, element, state, context, options) => {
37
37
  if (!(0, import_types.isFunction)(param)) return;
38
- return await param.call(
38
+ const result = param.call(
39
39
  element,
40
40
  element,
41
41
  state || element.state,
42
42
  context || element.context,
43
43
  options
44
44
  );
45
+ if (result && typeof result.then === "function") {
46
+ result.then(() => {
47
+ });
48
+ }
49
+ return result;
45
50
  };
46
- const triggerEventOn = async (param, element, options) => {
51
+ const triggerEventOn = (param, element, options) => {
47
52
  if (!element) {
48
53
  throw new Error("Element is required");
49
54
  }
50
55
  const appliedFunction = getOnOrPropsEvent(param, element);
51
56
  if (appliedFunction) {
52
57
  const { state, context } = element;
53
- return await applyEvent(appliedFunction, element, state, context, options);
58
+ return applyEvent(appliedFunction, element, state, context, options);
54
59
  }
55
60
  };
56
- const applyEventUpdate = async (param, updatedObj, element, state, context, options) => {
61
+ const applyEventUpdate = (param, updatedObj, element, state, context, options) => {
57
62
  if (!(0, import_types.isFunction)(param)) return;
58
- return await param.call(
63
+ const result = param.call(
59
64
  element,
60
65
  updatedObj,
61
66
  element,
@@ -63,12 +68,17 @@ const applyEventUpdate = async (param, updatedObj, element, state, context, opti
63
68
  context || element.context,
64
69
  options
65
70
  );
71
+ if (result && typeof result.then === "function") {
72
+ result.then(() => {
73
+ });
74
+ }
75
+ return result;
66
76
  };
67
- const triggerEventOnUpdate = async (param, updatedObj, element, options) => {
77
+ const triggerEventOnUpdate = (param, updatedObj, element, options) => {
68
78
  const appliedFunction = getOnOrPropsEvent(param, element);
69
79
  if (appliedFunction) {
70
80
  const { state, context } = element;
71
- return await applyEventUpdate(
81
+ return applyEventUpdate(
72
82
  appliedFunction,
73
83
  updatedObj,
74
84
  element,
@@ -84,9 +94,9 @@ const applyEventsOnNode = (element, options) => {
84
94
  if (import_keys.DOMQL_EVENTS.includes(param)) continue;
85
95
  const appliedFunction = getOnOrPropsEvent(param, element);
86
96
  if ((0, import_types.isFunction)(appliedFunction)) {
87
- node.addEventListener(param, async (event) => {
97
+ node.addEventListener(param, (event) => {
88
98
  const { state, context } = element;
89
- await appliedFunction.call(
99
+ const result = appliedFunction.call(
90
100
  element,
91
101
  event,
92
102
  element,
@@ -94,6 +104,10 @@ const applyEventsOnNode = (element, options) => {
94
104
  context,
95
105
  options
96
106
  );
107
+ if (result && typeof result.then === "function") {
108
+ result.then(() => {
109
+ });
110
+ }
97
111
  });
98
112
  }
99
113
  }
package/dist/esm/on.js CHANGED
@@ -6,29 +6,34 @@ const getOnOrPropsEvent = (param, element) => {
6
6
  const onPropEvent = (_b = element.props) == null ? void 0 : _b["on" + param.slice(0, 1).toUpperCase() + param.slice(1)];
7
7
  return onEvent || onPropEvent;
8
8
  };
9
- const applyEvent = async (param, element, state, context, options) => {
9
+ const applyEvent = (param, element, state, context, options) => {
10
10
  if (!isFunction(param)) return;
11
- return await param.call(
11
+ const result = param.call(
12
12
  element,
13
13
  element,
14
14
  state || element.state,
15
15
  context || element.context,
16
16
  options
17
17
  );
18
+ if (result && typeof result.then === "function") {
19
+ result.then(() => {
20
+ });
21
+ }
22
+ return result;
18
23
  };
19
- const triggerEventOn = async (param, element, options) => {
24
+ const triggerEventOn = (param, element, options) => {
20
25
  if (!element) {
21
26
  throw new Error("Element is required");
22
27
  }
23
28
  const appliedFunction = getOnOrPropsEvent(param, element);
24
29
  if (appliedFunction) {
25
30
  const { state, context } = element;
26
- return await applyEvent(appliedFunction, element, state, context, options);
31
+ return applyEvent(appliedFunction, element, state, context, options);
27
32
  }
28
33
  };
29
- const applyEventUpdate = async (param, updatedObj, element, state, context, options) => {
34
+ const applyEventUpdate = (param, updatedObj, element, state, context, options) => {
30
35
  if (!isFunction(param)) return;
31
- return await param.call(
36
+ const result = param.call(
32
37
  element,
33
38
  updatedObj,
34
39
  element,
@@ -36,12 +41,17 @@ const applyEventUpdate = async (param, updatedObj, element, state, context, opti
36
41
  context || element.context,
37
42
  options
38
43
  );
44
+ if (result && typeof result.then === "function") {
45
+ result.then(() => {
46
+ });
47
+ }
48
+ return result;
39
49
  };
40
- const triggerEventOnUpdate = async (param, updatedObj, element, options) => {
50
+ const triggerEventOnUpdate = (param, updatedObj, element, options) => {
41
51
  const appliedFunction = getOnOrPropsEvent(param, element);
42
52
  if (appliedFunction) {
43
53
  const { state, context } = element;
44
- return await applyEventUpdate(
54
+ return applyEventUpdate(
45
55
  appliedFunction,
46
56
  updatedObj,
47
57
  element,
@@ -57,9 +67,9 @@ const applyEventsOnNode = (element, options) => {
57
67
  if (DOMQL_EVENTS.includes(param)) continue;
58
68
  const appliedFunction = getOnOrPropsEvent(param, element);
59
69
  if (isFunction(appliedFunction)) {
60
- node.addEventListener(param, async (event) => {
70
+ node.addEventListener(param, (event) => {
61
71
  const { state, context } = element;
62
- await appliedFunction.call(
72
+ const result = appliedFunction.call(
63
73
  element,
64
74
  event,
65
75
  element,
@@ -67,6 +77,10 @@ const applyEventsOnNode = (element, options) => {
67
77
  context,
68
78
  options
69
79
  );
80
+ if (result && typeof result.then === "function") {
81
+ result.then(() => {
82
+ });
83
+ }
70
84
  });
71
85
  }
72
86
  }
package/on.js CHANGED
@@ -10,29 +10,33 @@ const getOnOrPropsEvent = (param, element) => {
10
10
  return onEvent || onPropEvent
11
11
  }
12
12
 
13
- export const applyEvent = async (param, element, state, context, options) => {
13
+ export const applyEvent = (param, element, state, context, options) => {
14
14
  if (!isFunction(param)) return
15
- return await param.call(
15
+ const result = param.call(
16
16
  element,
17
17
  element,
18
18
  state || element.state,
19
19
  context || element.context,
20
20
  options
21
21
  )
22
+ if (result && typeof result.then === 'function') {
23
+ result.then(() => {})
24
+ }
25
+ return result
22
26
  }
23
27
 
24
- export const triggerEventOn = async (param, element, options) => {
28
+ export const triggerEventOn = (param, element, options) => {
25
29
  if (!element) {
26
30
  throw new Error('Element is required')
27
31
  }
28
32
  const appliedFunction = getOnOrPropsEvent(param, element)
29
33
  if (appliedFunction) {
30
34
  const { state, context } = element
31
- return await applyEvent(appliedFunction, element, state, context, options)
35
+ return applyEvent(appliedFunction, element, state, context, options)
32
36
  }
33
37
  }
34
38
 
35
- export const applyEventUpdate = async (
39
+ export const applyEventUpdate = (
36
40
  param,
37
41
  updatedObj,
38
42
  element,
@@ -41,7 +45,7 @@ export const applyEventUpdate = async (
41
45
  options
42
46
  ) => {
43
47
  if (!isFunction(param)) return
44
- return await param.call(
48
+ const result = param.call(
45
49
  element,
46
50
  updatedObj,
47
51
  element,
@@ -49,18 +53,17 @@ export const applyEventUpdate = async (
49
53
  context || element.context,
50
54
  options
51
55
  )
56
+ if (result && typeof result.then === 'function') {
57
+ result.then(() => {})
58
+ }
59
+ return result
52
60
  }
53
61
 
54
- export const triggerEventOnUpdate = async (
55
- param,
56
- updatedObj,
57
- element,
58
- options
59
- ) => {
62
+ export const triggerEventOnUpdate = (param, updatedObj, element, options) => {
60
63
  const appliedFunction = getOnOrPropsEvent(param, element)
61
64
  if (appliedFunction) {
62
65
  const { state, context } = element
63
- return await applyEventUpdate(
66
+ return applyEventUpdate(
64
67
  appliedFunction,
65
68
  updatedObj,
66
69
  element,
@@ -78,9 +81,9 @@ export const applyEventsOnNode = (element, options) => {
78
81
 
79
82
  const appliedFunction = getOnOrPropsEvent(param, element)
80
83
  if (isFunction(appliedFunction)) {
81
- node.addEventListener(param, async event => {
84
+ node.addEventListener(param, event => {
82
85
  const { state, context } = element
83
- await appliedFunction.call(
86
+ const result = appliedFunction.call(
84
87
  element,
85
88
  event,
86
89
  element,
@@ -88,6 +91,9 @@ export const applyEventsOnNode = (element, options) => {
88
91
  context,
89
92
  options
90
93
  )
94
+ if (result && typeof result.then === 'function') {
95
+ result.then(() => {})
96
+ }
91
97
  })
92
98
  }
93
99
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@domql/event",
3
- "version": "3.1.1",
3
+ "version": "3.2.3",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "module": "index.js",
@@ -9,9 +9,9 @@
9
9
  "jsdelivr": "dist/iife/index.js",
10
10
  "exports": {
11
11
  ".": {
12
- "default": "./dist/esm/index.js",
13
12
  "import": "./dist/esm/index.js",
14
- "require": "./dist/cjs/index.js"
13
+ "require": "./dist/cjs/index.js",
14
+ "default": "./dist/esm/index.js"
15
15
  }
16
16
  },
17
17
  "source": "index.js",
@@ -21,15 +21,15 @@
21
21
  ],
22
22
  "scripts": {
23
23
  "copy:package:cjs": "cp ../../build/package-cjs.json dist/cjs/package.json",
24
- "build:esm": "npx esbuild *.js --target=es2017 --format=esm --outdir=dist/esm",
25
- "build:cjs": "npx esbuild *.js --target=node16 --format=cjs --outdir=dist/cjs",
26
- "build:iife": "npx esbuild *.js --target=node16 --format=iife --outdir=dist/iife",
24
+ "build:esm": "npx cross-env NODE_ENV=$NODE_ENV npx esbuild *.js --target=es2017 --format=esm --outdir=dist/esm",
25
+ "build:cjs": "npx cross-env NODE_ENV=$NODE_ENV npx esbuild *.js --target=node16 --format=cjs --outdir=dist/cjs",
26
+ "build:iife": "npx cross-env NODE_ENV=$NODE_ENV npx esbuild *.js --target=node16 --format=iife --outdir=dist/iife",
27
27
  "build": "npx rimraf -I dist; npm run build:cjs; npm run build:esm",
28
28
  "prepublish": "npm run build; npm run copy:package:cjs"
29
29
  },
30
30
  "dependencies": {
31
- "@domql/report": "^3.1.1",
32
- "@domql/utils": "^3.1.1"
31
+ "@domql/report": "^3.2.3",
32
+ "@domql/utils": "^3.2.3"
33
33
  },
34
- "gitHead": "39fb7a8c07355468ccce79e2f787ca3fa0715692"
34
+ "gitHead": "9fc1b79b41cdc725ca6b24aec64920a599634681"
35
35
  }