@domql/event 2.5.168 → 2.5.170
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 +13 -8
- package/on.js +13 -5
- package/package.json +3 -3
package/dist/cjs/on.js
CHANGED
|
@@ -27,24 +27,30 @@ __export(on_exports, {
|
|
|
27
27
|
});
|
|
28
28
|
module.exports = __toCommonJS(on_exports);
|
|
29
29
|
var import_utils = require("@domql/utils");
|
|
30
|
+
const getOnOrPropsEvent = (param, element) => {
|
|
31
|
+
var _a, _b;
|
|
32
|
+
const onEvent = (_a = element.on) == null ? void 0 : _a[param];
|
|
33
|
+
const onPropEvent = (_b = element.props) == null ? void 0 : _b["on" + param.slice(0, 1).toUpperCase() + param.slice(1)];
|
|
34
|
+
return onEvent || onPropEvent;
|
|
35
|
+
};
|
|
30
36
|
const applyEvent = (param, element, state, context, options) => {
|
|
31
37
|
return param.call(element, element, state || element.state, context || element.context, options);
|
|
32
38
|
};
|
|
33
39
|
const triggerEventOn = (param, element, options) => {
|
|
34
|
-
|
|
35
|
-
if (
|
|
40
|
+
const appliedFunction = getOnOrPropsEvent(param, element);
|
|
41
|
+
if (appliedFunction) {
|
|
36
42
|
const { state, context } = element;
|
|
37
|
-
return applyEvent(
|
|
43
|
+
return applyEvent(appliedFunction, element, state, context, options);
|
|
38
44
|
}
|
|
39
45
|
};
|
|
40
46
|
const applyEventUpdate = (param, updatedObj, element, state, context, options) => {
|
|
41
47
|
return param.call(element, updatedObj, element, state || element.state, context || element.context, options);
|
|
42
48
|
};
|
|
43
49
|
const triggerEventOnUpdate = (param, updatedObj, element, options) => {
|
|
44
|
-
|
|
45
|
-
if (
|
|
50
|
+
const appliedFunction = getOnOrPropsEvent(param, element);
|
|
51
|
+
if (appliedFunction) {
|
|
46
52
|
const { state, context } = element;
|
|
47
|
-
return applyEventUpdate(
|
|
53
|
+
return applyEventUpdate(appliedFunction, updatedObj, element, state, context, options);
|
|
48
54
|
}
|
|
49
55
|
};
|
|
50
56
|
const applyAnimationFrame = (element, options) => {
|
|
@@ -57,12 +63,11 @@ const applyAnimationFrame = (element, options) => {
|
|
|
57
63
|
}
|
|
58
64
|
};
|
|
59
65
|
const applyEventsOnNode = (element, options) => {
|
|
60
|
-
var _a;
|
|
61
66
|
const { node, on } = element;
|
|
62
67
|
for (const param in on) {
|
|
63
68
|
if (param === "init" || param === "beforeClassAssign" || param === "render" || param === "renderRouter" || param === "attachNode" || param === "stateInit" || param === "stateCreated" || param === "beforeStateUpdate" || param === "stateUpdate" || param === "beforeUpdate" || param === "done" || param === "create" || param === "complete" || param === "frame" || param === "update")
|
|
64
69
|
continue;
|
|
65
|
-
const appliedFunction =
|
|
70
|
+
const appliedFunction = getOnOrPropsEvent(param, element);
|
|
66
71
|
if ((0, import_utils.isFunction)(appliedFunction)) {
|
|
67
72
|
node.addEventListener(param, (event) => {
|
|
68
73
|
const { state, context } = element;
|
package/on.js
CHANGED
|
@@ -2,14 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
import { isFunction } from '@domql/utils'
|
|
4
4
|
|
|
5
|
+
const getOnOrPropsEvent = (param, element) => {
|
|
6
|
+
const onEvent = element.on?.[param]
|
|
7
|
+
const onPropEvent = element.props?.['on' + param.slice(0, 1).toUpperCase() + param.slice(1)]
|
|
8
|
+
return onEvent || onPropEvent
|
|
9
|
+
}
|
|
10
|
+
|
|
5
11
|
export const applyEvent = (param, element, state, context, options) => {
|
|
6
12
|
return param.call(element, element, state || element.state, context || element.context, options)
|
|
7
13
|
}
|
|
8
14
|
|
|
9
15
|
export const triggerEventOn = (param, element, options) => {
|
|
10
|
-
|
|
16
|
+
const appliedFunction = getOnOrPropsEvent(param, element)
|
|
17
|
+
if (appliedFunction) {
|
|
11
18
|
const { state, context } = element
|
|
12
|
-
return applyEvent(
|
|
19
|
+
return applyEvent(appliedFunction, element, state, context, options)
|
|
13
20
|
}
|
|
14
21
|
}
|
|
15
22
|
|
|
@@ -18,9 +25,10 @@ export const applyEventUpdate = (param, updatedObj, element, state, context, opt
|
|
|
18
25
|
}
|
|
19
26
|
|
|
20
27
|
export const triggerEventOnUpdate = (param, updatedObj, element, options) => {
|
|
21
|
-
|
|
28
|
+
const appliedFunction = getOnOrPropsEvent(param, element)
|
|
29
|
+
if (appliedFunction) {
|
|
22
30
|
const { state, context } = element
|
|
23
|
-
return applyEventUpdate(
|
|
31
|
+
return applyEventUpdate(appliedFunction, updatedObj, element, state, context, options)
|
|
24
32
|
}
|
|
25
33
|
}
|
|
26
34
|
|
|
@@ -54,7 +62,7 @@ export const applyEventsOnNode = (element, options) => {
|
|
|
54
62
|
param === 'update'
|
|
55
63
|
) continue
|
|
56
64
|
|
|
57
|
-
const appliedFunction =
|
|
65
|
+
const appliedFunction = getOnOrPropsEvent(param, element)
|
|
58
66
|
if (isFunction(appliedFunction)) {
|
|
59
67
|
node.addEventListener(param, event => {
|
|
60
68
|
const { state, context } = element
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@domql/event",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.170",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@domql/report": "^2.5.162",
|
|
31
|
-
"@domql/utils": "^2.5.
|
|
31
|
+
"@domql/utils": "^2.5.170"
|
|
32
32
|
},
|
|
33
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "44f9d2c4157170a03784d6abca2eee3604b97270"
|
|
34
34
|
}
|