@domql/event 2.30.1 → 2.31.0
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 +35 -5
- package/dist/esm/on.js +35 -5
- package/on.js +52 -9
- package/package.json +4 -4
package/dist/cjs/on.js
CHANGED
|
@@ -33,7 +33,14 @@ const getOnOrPropsEvent = (param, element) => {
|
|
|
33
33
|
return onEvent || onPropEvent;
|
|
34
34
|
};
|
|
35
35
|
const applyEvent = (param, element, state, context, options) => {
|
|
36
|
-
|
|
36
|
+
if (!param.call) element.warn(`Event is not executable: ${param}`);
|
|
37
|
+
return param.call(
|
|
38
|
+
element,
|
|
39
|
+
element,
|
|
40
|
+
state || element.state,
|
|
41
|
+
context || element.context,
|
|
42
|
+
options
|
|
43
|
+
);
|
|
37
44
|
};
|
|
38
45
|
const triggerEventOn = async (param, element, options) => {
|
|
39
46
|
const appliedFunction = getOnOrPropsEvent(param, element);
|
|
@@ -43,24 +50,47 @@ const triggerEventOn = async (param, element, options) => {
|
|
|
43
50
|
}
|
|
44
51
|
};
|
|
45
52
|
const applyEventUpdate = (param, updatedObj, element, state, context, options) => {
|
|
46
|
-
|
|
53
|
+
if (!param.call) element.warn(`Event is not executable: ${param}`);
|
|
54
|
+
return param.call(
|
|
55
|
+
element,
|
|
56
|
+
updatedObj,
|
|
57
|
+
element,
|
|
58
|
+
state || element.state,
|
|
59
|
+
context || element.context,
|
|
60
|
+
options
|
|
61
|
+
);
|
|
47
62
|
};
|
|
48
63
|
const triggerEventOnUpdate = async (param, updatedObj, element, options) => {
|
|
49
64
|
const appliedFunction = getOnOrPropsEvent(param, element);
|
|
50
65
|
if (appliedFunction) {
|
|
51
66
|
const { state, context } = element;
|
|
52
|
-
return await applyEventUpdate(
|
|
67
|
+
return await applyEventUpdate(
|
|
68
|
+
appliedFunction,
|
|
69
|
+
updatedObj,
|
|
70
|
+
element,
|
|
71
|
+
state,
|
|
72
|
+
context,
|
|
73
|
+
options
|
|
74
|
+
);
|
|
53
75
|
}
|
|
54
76
|
};
|
|
55
77
|
const applyEventsOnNode = (element, options) => {
|
|
56
78
|
const { node, on } = element;
|
|
57
79
|
for (const param in on) {
|
|
58
|
-
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")
|
|
80
|
+
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")
|
|
81
|
+
continue;
|
|
59
82
|
const appliedFunction = getOnOrPropsEvent(param, element);
|
|
60
83
|
if ((0, import_utils.isFunction)(appliedFunction)) {
|
|
61
84
|
node.addEventListener(param, async (event) => {
|
|
62
85
|
const { state, context } = element;
|
|
63
|
-
await appliedFunction.call(
|
|
86
|
+
await appliedFunction.call(
|
|
87
|
+
element,
|
|
88
|
+
event,
|
|
89
|
+
element,
|
|
90
|
+
state,
|
|
91
|
+
context,
|
|
92
|
+
options
|
|
93
|
+
);
|
|
64
94
|
});
|
|
65
95
|
}
|
|
66
96
|
}
|
package/dist/esm/on.js
CHANGED
|
@@ -6,7 +6,14 @@ const getOnOrPropsEvent = (param, element) => {
|
|
|
6
6
|
return onEvent || onPropEvent;
|
|
7
7
|
};
|
|
8
8
|
const applyEvent = (param, element, state, context, options) => {
|
|
9
|
-
|
|
9
|
+
if (!param.call) element.warn(`Event is not executable: ${param}`);
|
|
10
|
+
return param.call(
|
|
11
|
+
element,
|
|
12
|
+
element,
|
|
13
|
+
state || element.state,
|
|
14
|
+
context || element.context,
|
|
15
|
+
options
|
|
16
|
+
);
|
|
10
17
|
};
|
|
11
18
|
const triggerEventOn = async (param, element, options) => {
|
|
12
19
|
const appliedFunction = getOnOrPropsEvent(param, element);
|
|
@@ -16,24 +23,47 @@ const triggerEventOn = async (param, element, options) => {
|
|
|
16
23
|
}
|
|
17
24
|
};
|
|
18
25
|
const applyEventUpdate = (param, updatedObj, element, state, context, options) => {
|
|
19
|
-
|
|
26
|
+
if (!param.call) element.warn(`Event is not executable: ${param}`);
|
|
27
|
+
return param.call(
|
|
28
|
+
element,
|
|
29
|
+
updatedObj,
|
|
30
|
+
element,
|
|
31
|
+
state || element.state,
|
|
32
|
+
context || element.context,
|
|
33
|
+
options
|
|
34
|
+
);
|
|
20
35
|
};
|
|
21
36
|
const triggerEventOnUpdate = async (param, updatedObj, element, options) => {
|
|
22
37
|
const appliedFunction = getOnOrPropsEvent(param, element);
|
|
23
38
|
if (appliedFunction) {
|
|
24
39
|
const { state, context } = element;
|
|
25
|
-
return await applyEventUpdate(
|
|
40
|
+
return await applyEventUpdate(
|
|
41
|
+
appliedFunction,
|
|
42
|
+
updatedObj,
|
|
43
|
+
element,
|
|
44
|
+
state,
|
|
45
|
+
context,
|
|
46
|
+
options
|
|
47
|
+
);
|
|
26
48
|
}
|
|
27
49
|
};
|
|
28
50
|
const applyEventsOnNode = (element, options) => {
|
|
29
51
|
const { node, on } = element;
|
|
30
52
|
for (const param in on) {
|
|
31
|
-
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")
|
|
53
|
+
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")
|
|
54
|
+
continue;
|
|
32
55
|
const appliedFunction = getOnOrPropsEvent(param, element);
|
|
33
56
|
if (isFunction(appliedFunction)) {
|
|
34
57
|
node.addEventListener(param, async (event) => {
|
|
35
58
|
const { state, context } = element;
|
|
36
|
-
await appliedFunction.call(
|
|
59
|
+
await appliedFunction.call(
|
|
60
|
+
element,
|
|
61
|
+
event,
|
|
62
|
+
element,
|
|
63
|
+
state,
|
|
64
|
+
context,
|
|
65
|
+
options
|
|
66
|
+
);
|
|
37
67
|
});
|
|
38
68
|
}
|
|
39
69
|
}
|
package/on.js
CHANGED
|
@@ -4,12 +4,20 @@ import { isFunction } from '@domql/utils'
|
|
|
4
4
|
|
|
5
5
|
const getOnOrPropsEvent = (param, element) => {
|
|
6
6
|
const onEvent = element.on?.[param]
|
|
7
|
-
const onPropEvent =
|
|
7
|
+
const onPropEvent =
|
|
8
|
+
element.props?.['on' + param.slice(0, 1).toUpperCase() + param.slice(1)]
|
|
8
9
|
return onEvent || onPropEvent
|
|
9
10
|
}
|
|
10
11
|
|
|
11
12
|
export const applyEvent = (param, element, state, context, options) => {
|
|
12
|
-
|
|
13
|
+
if (!param.call) element.warn(`Event is not executable: ${param}`)
|
|
14
|
+
return param.call(
|
|
15
|
+
element,
|
|
16
|
+
element,
|
|
17
|
+
state || element.state,
|
|
18
|
+
context || element.context,
|
|
19
|
+
options
|
|
20
|
+
)
|
|
13
21
|
}
|
|
14
22
|
|
|
15
23
|
export const triggerEventOn = async (param, element, options) => {
|
|
@@ -20,15 +28,42 @@ export const triggerEventOn = async (param, element, options) => {
|
|
|
20
28
|
}
|
|
21
29
|
}
|
|
22
30
|
|
|
23
|
-
export const applyEventUpdate = (
|
|
24
|
-
|
|
31
|
+
export const applyEventUpdate = (
|
|
32
|
+
param,
|
|
33
|
+
updatedObj,
|
|
34
|
+
element,
|
|
35
|
+
state,
|
|
36
|
+
context,
|
|
37
|
+
options
|
|
38
|
+
) => {
|
|
39
|
+
if (!param.call) element.warn(`Event is not executable: ${param}`)
|
|
40
|
+
return param.call(
|
|
41
|
+
element,
|
|
42
|
+
updatedObj,
|
|
43
|
+
element,
|
|
44
|
+
state || element.state,
|
|
45
|
+
context || element.context,
|
|
46
|
+
options
|
|
47
|
+
)
|
|
25
48
|
}
|
|
26
49
|
|
|
27
|
-
export const triggerEventOnUpdate = async (
|
|
50
|
+
export const triggerEventOnUpdate = async (
|
|
51
|
+
param,
|
|
52
|
+
updatedObj,
|
|
53
|
+
element,
|
|
54
|
+
options
|
|
55
|
+
) => {
|
|
28
56
|
const appliedFunction = getOnOrPropsEvent(param, element)
|
|
29
57
|
if (appliedFunction) {
|
|
30
58
|
const { state, context } = element
|
|
31
|
-
return await applyEventUpdate(
|
|
59
|
+
return await applyEventUpdate(
|
|
60
|
+
appliedFunction,
|
|
61
|
+
updatedObj,
|
|
62
|
+
element,
|
|
63
|
+
state,
|
|
64
|
+
context,
|
|
65
|
+
options
|
|
66
|
+
)
|
|
32
67
|
}
|
|
33
68
|
}
|
|
34
69
|
|
|
@@ -51,13 +86,21 @@ export const applyEventsOnNode = (element, options) => {
|
|
|
51
86
|
param === 'complete' ||
|
|
52
87
|
param === 'frame' ||
|
|
53
88
|
param === 'update'
|
|
54
|
-
)
|
|
89
|
+
)
|
|
90
|
+
continue
|
|
55
91
|
|
|
56
92
|
const appliedFunction = getOnOrPropsEvent(param, element)
|
|
57
93
|
if (isFunction(appliedFunction)) {
|
|
58
|
-
node.addEventListener(param, async event => {
|
|
94
|
+
node.addEventListener(param, async (event) => {
|
|
59
95
|
const { state, context } = element
|
|
60
|
-
await appliedFunction.call(
|
|
96
|
+
await appliedFunction.call(
|
|
97
|
+
element,
|
|
98
|
+
event,
|
|
99
|
+
element,
|
|
100
|
+
state,
|
|
101
|
+
context,
|
|
102
|
+
options
|
|
103
|
+
)
|
|
61
104
|
})
|
|
62
105
|
}
|
|
63
106
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@domql/event",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.31.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "index.js",
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
"prepublish": "npm run build; npm run copy:package:cjs"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@domql/report": "^2.
|
|
32
|
-
"@domql/utils": "^2.
|
|
31
|
+
"@domql/report": "^2.31.0",
|
|
32
|
+
"@domql/utils": "^2.31.0"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "dd5c64895320d678f28ca585c9fd4e4550a483cd"
|
|
35
35
|
}
|