domql 1.5.51 → 1.5.53
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 +1 -8
- package/src/element/create.js +5 -5
- package/src/element/set.js +0 -1
- package/src/element/state.js +11 -11
- package/src/element/update.js +3 -3
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.53",
|
|
7
7
|
"repository": "https://github.com/domql/domql",
|
|
8
8
|
"publishConfig": {
|
|
9
9
|
"registry": "https://registry.npmjs.org"
|
|
@@ -22,13 +22,6 @@
|
|
|
22
22
|
"bump": "npx np"
|
|
23
23
|
},
|
|
24
24
|
"source": true,
|
|
25
|
-
"dependencies": {
|
|
26
|
-
"@domql/utils": "latest",
|
|
27
|
-
"@swc/helpers": "^0.4.12"
|
|
28
|
-
},
|
|
29
|
-
"peerDependencies": {
|
|
30
|
-
"@emotion/css": "^11.10.0"
|
|
31
|
-
},
|
|
32
25
|
"devDependencies": {
|
|
33
26
|
"@babel/core": "^7.16.0",
|
|
34
27
|
"@babel/eslint-parser": "^7.16.3",
|
package/src/element/create.js
CHANGED
|
@@ -28,8 +28,7 @@ const create = (element, parent, key, options = OPTIONS.create || {}) => {
|
|
|
28
28
|
|
|
29
29
|
// if ELEMENT is not given
|
|
30
30
|
if (element === undefined) {
|
|
31
|
-
if (ENV === 'test' || ENV === 'development')
|
|
32
|
-
console.warn(key, 'element is undefined in', parent && parent.path)
|
|
31
|
+
if (ENV === 'test' || ENV === 'development') { console.warn(key, 'element is undefined in', parent && parent.path) }
|
|
33
32
|
element = {}
|
|
34
33
|
}
|
|
35
34
|
if (element === null) return
|
|
@@ -96,9 +95,9 @@ const create = (element, parent, key, options = OPTIONS.create || {}) => {
|
|
|
96
95
|
|
|
97
96
|
if (options.components) {
|
|
98
97
|
const { components } = options
|
|
99
|
-
const { extend
|
|
98
|
+
const { extend } = element
|
|
100
99
|
const execExtend = exec(extend, element)
|
|
101
|
-
if (isString(execExtend))
|
|
100
|
+
if (isString(execExtend)) {
|
|
102
101
|
if (components[execExtend]) element.extend = components[execExtend]
|
|
103
102
|
else {
|
|
104
103
|
if (ENV === 'test' || ENV === 'development') {
|
|
@@ -107,6 +106,7 @@ const create = (element, parent, key, options = OPTIONS.create || {}) => {
|
|
|
107
106
|
}
|
|
108
107
|
element.extend = {}
|
|
109
108
|
}
|
|
109
|
+
}
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
// assign context
|
|
@@ -228,7 +228,7 @@ const create = (element, parent, key, options = OPTIONS.create || {}) => {
|
|
|
228
228
|
|
|
229
229
|
export const isKeyComponent = (key) => {
|
|
230
230
|
const isFirstKeyString = isString(key)
|
|
231
|
-
if(!isFirstKeyString) return
|
|
231
|
+
if (!isFirstKeyString) return
|
|
232
232
|
|
|
233
233
|
const firstCharKey = key.slice(0, 1)
|
|
234
234
|
|
package/src/element/set.js
CHANGED
package/src/element/state.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
import { on } from '../event'
|
|
4
|
-
import {
|
|
5
|
-
import { is, isObject, isFunction
|
|
4
|
+
import { deepClone, exec, overwriteDeep } from '../utils'
|
|
5
|
+
import { is, isObject, isFunction } from '@domql/utils'
|
|
6
6
|
|
|
7
7
|
export const IGNORE_STATE_PARAMS = [
|
|
8
8
|
'update', 'parse', 'clean', 'parent', '__element', '__depends', '__ref', '__root',
|
|
@@ -56,7 +56,7 @@ export const updateState = function (obj, options = {}) {
|
|
|
56
56
|
const initReturns = on.initStateUpdated(element.on.initStateUpdated, element, state, obj)
|
|
57
57
|
if (initReturns === false) return
|
|
58
58
|
}
|
|
59
|
-
|
|
59
|
+
|
|
60
60
|
if (element.__state) {
|
|
61
61
|
if (state.parent && state.parent[element.__state]) {
|
|
62
62
|
const keyInParentState = state.parent[element.__state]
|
|
@@ -70,7 +70,7 @@ export const updateState = function (obj, options = {}) {
|
|
|
70
70
|
|
|
71
71
|
// TODO: try debounce
|
|
72
72
|
if (!options.preventUpdate) element.update({}, options)
|
|
73
|
-
|
|
73
|
+
|
|
74
74
|
if (state.__depends) {
|
|
75
75
|
for (const el in state.__depends) {
|
|
76
76
|
const findElement = state.__depends[el]
|
|
@@ -85,30 +85,30 @@ export const updateState = function (obj, options = {}) {
|
|
|
85
85
|
|
|
86
86
|
export default function (element, parent) {
|
|
87
87
|
let { state, __root } = element
|
|
88
|
-
|
|
88
|
+
|
|
89
89
|
if (isFunction(state)) state = exec(state, element)
|
|
90
90
|
|
|
91
91
|
if (is(state)('string', 'number')) {
|
|
92
|
-
element.__state = state
|
|
92
|
+
element.__state = state
|
|
93
93
|
state = {}
|
|
94
94
|
}
|
|
95
95
|
if (state === true) {
|
|
96
|
-
element.__state = element.key
|
|
96
|
+
element.__state = element.key
|
|
97
97
|
state = {}
|
|
98
98
|
}
|
|
99
|
-
|
|
99
|
+
|
|
100
100
|
if (!state) {
|
|
101
101
|
if (parent && parent.state) return parent.state
|
|
102
102
|
return {}
|
|
103
103
|
} else {
|
|
104
104
|
element.__hasRootState = true
|
|
105
105
|
}
|
|
106
|
-
|
|
106
|
+
|
|
107
107
|
// run `on.init`
|
|
108
108
|
if (element.on && isFunction(element.on.stateInit)) {
|
|
109
109
|
on.stateInit(element.on.stateInit, element, element.state)
|
|
110
110
|
}
|
|
111
|
-
|
|
111
|
+
|
|
112
112
|
if (element.__state) {
|
|
113
113
|
if (parent && parent.state && parent.state[element.__state]) {
|
|
114
114
|
const keyInParentState = parent.state[element.__state]
|
|
@@ -126,7 +126,7 @@ export default function (element, parent) {
|
|
|
126
126
|
state = deepClone(__ref, IGNORE_STATE_PARAMS)
|
|
127
127
|
if (isObject(__ref.__depends)) {
|
|
128
128
|
__ref.__depends[element.key] = state
|
|
129
|
-
} else __ref.__depends = { [element.key]
|
|
129
|
+
} else __ref.__depends = { [element.key]: state }
|
|
130
130
|
} else {
|
|
131
131
|
state = deepClone(state, IGNORE_STATE_PARAMS)
|
|
132
132
|
}
|
package/src/element/update.js
CHANGED
|
@@ -54,7 +54,7 @@ const update = function (params = {}, options = UPDATE_DEFAULT_OPTIONS) {
|
|
|
54
54
|
element.__ifFalsy = true
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
|
-
|
|
57
|
+
|
|
58
58
|
if (element.__state) {
|
|
59
59
|
const keyInParentState = parent.state[element.__state]
|
|
60
60
|
if (keyInParentState) {
|
|
@@ -106,10 +106,10 @@ const update = function (params = {}, options = UPDATE_DEFAULT_OPTIONS) {
|
|
|
106
106
|
}
|
|
107
107
|
} else if (prop && isObject(prop) && !hasDefined && !hasOptionsDefine) {
|
|
108
108
|
if (!options.preventRecursive) {
|
|
109
|
-
const childUpdateCall = () => update.call(prop, params[prop], {
|
|
109
|
+
const childUpdateCall = () => update.call(prop, params[prop], {
|
|
110
110
|
...options,
|
|
111
111
|
currentSnapshot: snapshotOnCallee,
|
|
112
|
-
calleeElement: element
|
|
112
|
+
calleeElement: element
|
|
113
113
|
})
|
|
114
114
|
if (element.props.lazyLoad || options.lazyLoad) {
|
|
115
115
|
window.requestAnimationFrame(() => childUpdateCall())
|