@domql/event 2.3.89 → 2.3.92
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/can.js +7 -7
- package/index.js +2 -9
- package/legacy.js +49 -0
- package/on.js +29 -54
- package/package.json +2 -2
package/can.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
import { TAGS } from '@domql/registry'
|
|
4
|
+
import { report } from '@domql/report'
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
export const canRender = (element) => {
|
|
7
|
+
const tag = element.tag || 'div'
|
|
8
|
+
const isValid = TAGS.body.indexOf(tag) > -1
|
|
9
|
+
return isValid || report('HTMLInvalidTag')
|
|
10
|
+
}
|
package/index.js
CHANGED
|
@@ -1,16 +1,9 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
import * as on from './on'
|
|
4
|
-
import * as can from './can'
|
|
5
3
|
import * as is from './is'
|
|
6
4
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
export * from './on'
|
|
6
|
+
export * from './can'
|
|
10
7
|
export {
|
|
11
|
-
on,
|
|
12
|
-
applyEvent,
|
|
13
|
-
triggerEventOn,
|
|
14
|
-
can,
|
|
15
8
|
is
|
|
16
9
|
}
|
package/legacy.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { isFunction } from '@domql/utils'
|
|
2
|
+
|
|
3
|
+
// LEGACY
|
|
4
|
+
export const init = (param, element, state) => {
|
|
5
|
+
param(element, state)
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export const render = (param, element, state) => {
|
|
9
|
+
param(element, state)
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// export const attachNode = (param, element, state) => {
|
|
13
|
+
// param(element, state)
|
|
14
|
+
// }
|
|
15
|
+
|
|
16
|
+
export const createState = (state, element) => {
|
|
17
|
+
const { on, ...el } = element
|
|
18
|
+
if (on && isFunction(on.createState)) {
|
|
19
|
+
on.createState(state, el)
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const updateStateInit = (changes, element) => {
|
|
24
|
+
const { state, on, ...el } = element
|
|
25
|
+
if (on && isFunction(on.updateStateInit)) {
|
|
26
|
+
on.updateStateInit(changes, state, el)
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export const updateState = (changes, element) => {
|
|
31
|
+
const { state, on } = element
|
|
32
|
+
if (on && isFunction(on.updateState)) {
|
|
33
|
+
on.updateState(changes, state, element)
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export const propsUpdated = (element) => {
|
|
38
|
+
const { props, state, on } = element
|
|
39
|
+
if (on && isFunction(on.propsUpdated)) {
|
|
40
|
+
on.propsUpdated(props, state, element)
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export const update = (params, element, state) => {
|
|
45
|
+
if (element.on && isFunction(element.on.update)) {
|
|
46
|
+
element.on.update(element, state)
|
|
47
|
+
}
|
|
48
|
+
return params
|
|
49
|
+
}
|
package/on.js
CHANGED
|
@@ -2,67 +2,42 @@
|
|
|
2
2
|
|
|
3
3
|
import { isFunction } from '@domql/utils'
|
|
4
4
|
|
|
5
|
-
export const
|
|
6
|
-
param(element, state)
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export const render = (param, element, state) => {
|
|
10
|
-
param(element, state)
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export const applyEvent = (param, element, state, context) => {
|
|
5
|
+
export const applyEvent = (param, element, state, context, updatedObj) => {
|
|
6
|
+
if (updatedObj) return param(updatedObj, element, state || element.state, context || element.context)
|
|
14
7
|
return param(element, state || element.state, context || element.context)
|
|
15
8
|
}
|
|
16
9
|
|
|
17
|
-
export const triggerEventOn = (param, element) => {
|
|
10
|
+
export const triggerEventOn = (param, element, updatedObj) => {
|
|
18
11
|
if (element.on && isFunction(element.on[param])) {
|
|
12
|
+
if (updatedObj) {
|
|
13
|
+
const { state, context } = element
|
|
14
|
+
return applyEvent(element.on[param], element, state, context, updatedObj)
|
|
15
|
+
}
|
|
19
16
|
return applyEvent(element.on[param], element)
|
|
20
17
|
}
|
|
21
18
|
}
|
|
22
19
|
|
|
23
|
-
export const
|
|
24
|
-
const {
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
on.updateStateInit(changes, state, el)
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export const updateState = (changes, element) => {
|
|
50
|
-
const { state, on } = element
|
|
51
|
-
if (on && isFunction(on.updateState)) {
|
|
52
|
-
on.updateState(changes, state, element)
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export const propsUpdated = (element) => {
|
|
57
|
-
const { props, state, on } = element
|
|
58
|
-
if (on && isFunction(on.propsUpdated)) {
|
|
59
|
-
on.propsUpdated(props, state, element)
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export const update = (params, element, state) => {
|
|
64
|
-
if (element.on && isFunction(element.on.update)) {
|
|
65
|
-
element.on.update(element, state)
|
|
20
|
+
export const applyEventsOnNode = element => {
|
|
21
|
+
const { node, on } = element
|
|
22
|
+
for (const param in on) {
|
|
23
|
+
if (
|
|
24
|
+
param === 'init' ||
|
|
25
|
+
param === 'beforeClassAssign' ||
|
|
26
|
+
param === 'render' ||
|
|
27
|
+
param === 'renderRouter' ||
|
|
28
|
+
param === 'attachNode' ||
|
|
29
|
+
param === 'stateInit' ||
|
|
30
|
+
param === 'stateCreated' ||
|
|
31
|
+
param === 'initStateUpdated' ||
|
|
32
|
+
param === 'stateUpdated' ||
|
|
33
|
+
param === 'initUpdate' ||
|
|
34
|
+
param === 'update'
|
|
35
|
+
) continue
|
|
36
|
+
|
|
37
|
+
const appliedFunction = element.on[param]
|
|
38
|
+
if (isFunction(appliedFunction)) {
|
|
39
|
+
const { state, context } = element
|
|
40
|
+
node.addEventListener(param, event => appliedFunction(event, element, state, context))
|
|
41
|
+
}
|
|
66
42
|
}
|
|
67
|
-
return params
|
|
68
43
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@domql/event",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.92",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"scripts": {
|
|
@@ -10,6 +10,6 @@
|
|
|
10
10
|
"@domql/globals": "latest",
|
|
11
11
|
"@domql/utils": "latest"
|
|
12
12
|
},
|
|
13
|
-
"gitHead": "
|
|
13
|
+
"gitHead": "dc86022df601a498fca8c9af5be9e40dcf36ddbf",
|
|
14
14
|
"source": "index.js"
|
|
15
15
|
}
|