domql 1.5.61 → 1.5.63
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/package.json +5 -2
- package/packages/emotion/index.js +4 -4
- package/src/element/create.js +8 -2
- package/src/element/state.js +17 -6
- package/src/utils/object.js +4 -4
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "DOM rendering Javascript framework at early stage.",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "symbo.ls",
|
|
6
|
-
"version": "1.5.
|
|
6
|
+
"version": "1.5.63",
|
|
7
7
|
"repository": "https://github.com/domql/domql",
|
|
8
8
|
"publishConfig": {
|
|
9
9
|
"registry": "https://registry.npmjs.org"
|
|
@@ -70,5 +70,8 @@
|
|
|
70
70
|
"browserslist": [
|
|
71
71
|
"> 1%",
|
|
72
72
|
"ie >= 9"
|
|
73
|
-
]
|
|
73
|
+
],
|
|
74
|
+
"dependencies": {
|
|
75
|
+
"@domql/utils": "^2.3.14"
|
|
76
|
+
}
|
|
74
77
|
}
|
|
@@ -7,11 +7,11 @@ import createEmotion from '@emotion/css/create-instance'
|
|
|
7
7
|
const ENV = process.env.NODE_ENV
|
|
8
8
|
|
|
9
9
|
export const transformEmotionStyle = (emotion, live) => {
|
|
10
|
-
return
|
|
11
|
-
const
|
|
10
|
+
return (params, element, node) => {
|
|
11
|
+
const execParams = exec(params, element)
|
|
12
12
|
if (params) {
|
|
13
|
-
if (isObjectLike(element.class)) element.class.elementStyle =
|
|
14
|
-
else element.class = { elementStyle:
|
|
13
|
+
if (isObjectLike(element.class)) element.class.elementStyle = execParams
|
|
14
|
+
else element.class = { elementStyle: execParams }
|
|
15
15
|
}
|
|
16
16
|
transformEmotionClass(emotion, live)(element.class, element, node, true)
|
|
17
17
|
}
|
package/src/element/create.js
CHANGED
|
@@ -55,7 +55,7 @@ const create = (element, parent, key, options = OPTIONS.create || {}) => {
|
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
// define KEY
|
|
58
|
-
const assignedKey = element.key || key || createID()
|
|
58
|
+
const assignedKey = (element.key || key || createID()).toString()
|
|
59
59
|
|
|
60
60
|
const { extend, props, state, childExtend, childProps } = element
|
|
61
61
|
|
|
@@ -109,6 +109,12 @@ const create = (element, parent, key, options = OPTIONS.create || {}) => {
|
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
+
// Only resolve extends, skip everything else
|
|
113
|
+
if (options.onlyResolveExtends) {
|
|
114
|
+
applyExtend(element, parent, options)
|
|
115
|
+
return element;
|
|
116
|
+
}
|
|
117
|
+
|
|
112
118
|
// assign context
|
|
113
119
|
if (options.context && !root.context) root.context = options.context
|
|
114
120
|
element.context = root.context
|
|
@@ -199,7 +205,7 @@ const create = (element, parent, key, options = OPTIONS.create || {}) => {
|
|
|
199
205
|
on.init(element.on.init, element, element.state)
|
|
200
206
|
}
|
|
201
207
|
|
|
202
|
-
// run `on.
|
|
208
|
+
// run `on.beforeClassAssign`
|
|
203
209
|
if (element.on && isFunction(element.on.beforeClassAssign)) {
|
|
204
210
|
on.beforeClassAssign(element.on.beforeClassAssign, element, element.state)
|
|
205
211
|
}
|
package/src/element/state.js
CHANGED
|
@@ -50,6 +50,9 @@ export const projectStateUpdate = function (obj, options = {}) {
|
|
|
50
50
|
export const updateState = function (obj, options = {}) {
|
|
51
51
|
const state = this
|
|
52
52
|
const element = state.__element
|
|
53
|
+
state.parent = element.parent.state
|
|
54
|
+
|
|
55
|
+
if (!state.__element) createState(element, element.parent)
|
|
53
56
|
|
|
54
57
|
// run `on.stateUpdated`
|
|
55
58
|
if (element.on && isFunction(element.on.initStateUpdated)) {
|
|
@@ -57,11 +60,13 @@ export const updateState = function (obj, options = {}) {
|
|
|
57
60
|
if (initReturns === false) return
|
|
58
61
|
}
|
|
59
62
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
+
const stateKey = element.__state
|
|
64
|
+
if (stateKey) {
|
|
65
|
+
// TODO: check for double parent
|
|
66
|
+
if (state.parent && state.parent[stateKey]) {
|
|
67
|
+
const keyInParentState = state.parent[stateKey]
|
|
63
68
|
if (keyInParentState && !options.stopStatePropogation) {
|
|
64
|
-
return state.parent.update({ [
|
|
69
|
+
return state.parent.update({ [stateKey]: obj }, options)
|
|
65
70
|
}
|
|
66
71
|
}
|
|
67
72
|
} else {
|
|
@@ -69,7 +74,10 @@ export const updateState = function (obj, options = {}) {
|
|
|
69
74
|
}
|
|
70
75
|
|
|
71
76
|
// TODO: try debounce
|
|
72
|
-
if (!options.preventUpdate
|
|
77
|
+
if (!options.preventUpdate)
|
|
78
|
+
element.update({}, options)
|
|
79
|
+
else if (options.preventUpdate === 'recursive')
|
|
80
|
+
element.update({}, { ...options, preventUpdate: true })
|
|
73
81
|
|
|
74
82
|
if (state.__depends) {
|
|
75
83
|
for (const el in state.__depends) {
|
|
@@ -83,7 +91,7 @@ export const updateState = function (obj, options = {}) {
|
|
|
83
91
|
}
|
|
84
92
|
}
|
|
85
93
|
|
|
86
|
-
export
|
|
94
|
+
export const createState = function (element, parent) {
|
|
87
95
|
let { state, __root } = element
|
|
88
96
|
|
|
89
97
|
if (isFunction(state)) state = exec(state, element)
|
|
@@ -150,6 +158,7 @@ export default function (element, parent) {
|
|
|
150
158
|
state.clean = cleanState
|
|
151
159
|
state.parse = parseState
|
|
152
160
|
state.update = updateState
|
|
161
|
+
state.create = createState
|
|
153
162
|
state.parent = element.parent.state
|
|
154
163
|
state.__element = element
|
|
155
164
|
state.__root = __root ? __root.state : state
|
|
@@ -169,3 +178,5 @@ export default function (element, parent) {
|
|
|
169
178
|
|
|
170
179
|
return state
|
|
171
180
|
}
|
|
181
|
+
|
|
182
|
+
export default createState
|
package/src/utils/object.js
CHANGED
|
@@ -17,11 +17,11 @@ export const memoize = (fn) => {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
export const debounce = (element, func, timeout = 300) => {
|
|
20
|
-
let timer
|
|
20
|
+
let timer
|
|
21
21
|
return (...args) => {
|
|
22
|
-
clearTimeout(timer)
|
|
23
|
-
timer = setTimeout(() => { func.apply(element, args) }, timeout)
|
|
24
|
-
}
|
|
22
|
+
clearTimeout(timer)
|
|
23
|
+
timer = setTimeout(() => { func.apply(element, args) }, timeout)
|
|
24
|
+
}
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
export const isTagRegistered = arg => nodes.body.indexOf(arg)
|