domql 1.5.33 → 1.5.35
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 +3 -3
- package/packages/emotion/index.js +13 -9
- package/src/element/iterate.js +27 -7
- package/src/element/mixins/classList.js +1 -1
- package/src/element/node.js +11 -3
- package/src/element/update.js +12 -3
- package/src/utils/object.js +1 -1
package/package.json
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"name": "domql",
|
|
3
3
|
"description": "DOM rendering Javascript framework at early stage.",
|
|
4
4
|
"private": false,
|
|
5
|
-
"author": "
|
|
6
|
-
"version": "1.5.
|
|
7
|
-
"repository": "https://github.com/
|
|
5
|
+
"author": "symbo.ls",
|
|
6
|
+
"version": "1.5.35",
|
|
7
|
+
"repository": "https://github.com/domql/domql",
|
|
8
8
|
"publishConfig": {
|
|
9
9
|
"registry": "https://registry.npmjs.org"
|
|
10
10
|
},
|
|
@@ -6,19 +6,19 @@ import { classList } from '../../src/element/mixins'
|
|
|
6
6
|
import createEmotion from '@emotion/css/create-instance'
|
|
7
7
|
const ENV = process.env.NODE_ENV
|
|
8
8
|
|
|
9
|
-
export const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const style = (params, element, node) => {
|
|
9
|
+
export const transformEmotionStyle = (emotion, live) => {
|
|
10
|
+
return (params, element, node) => {
|
|
13
11
|
const execPareams = exec(params, element)
|
|
14
12
|
if (params) {
|
|
15
13
|
if (isObjectLike(element.class)) element.class.elementStyle = execPareams
|
|
16
14
|
else element.class = { elementStyle: execPareams }
|
|
17
15
|
}
|
|
18
|
-
|
|
16
|
+
transformEmotionClass(emotion, live)(element.class, element, node, true)
|
|
19
17
|
}
|
|
18
|
+
}
|
|
20
19
|
|
|
21
|
-
|
|
20
|
+
export const transformEmotionClass = (emotion, live) => {
|
|
21
|
+
return (params, element, state, flag) => {
|
|
22
22
|
if (element.style && !flag) return
|
|
23
23
|
const { __class, __classNames } = element
|
|
24
24
|
if (!isObjectLike(params)) return
|
|
@@ -40,12 +40,16 @@ export const initDOMQLEmotion = (emotion, options) => {
|
|
|
40
40
|
__classNames[key] = CSSed
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
|
-
classList(__classNames, element, node)
|
|
43
|
+
classList(__classNames, element, element.node, live)
|
|
44
44
|
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export const initDOMQLEmotion = (emotion, options) => {
|
|
48
|
+
if (!emotion) emotion = createEmotion(options || { key: 'smbls' })
|
|
45
49
|
|
|
46
50
|
DOM.define({
|
|
47
|
-
style,
|
|
48
|
-
class:
|
|
51
|
+
style: transformEmotionStyle(emotion),
|
|
52
|
+
class: transformEmotionClass(emotion)
|
|
49
53
|
}, {
|
|
50
54
|
overwrite: true
|
|
51
55
|
})
|
package/src/element/iterate.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
import { exec, isFunction, isNumber, isString, overwrite } from '../utils'
|
|
3
|
+
import { isObject, exec, isFunction, isNumber, isString, overwrite } from '../utils'
|
|
4
4
|
import { isMethod } from './methods'
|
|
5
5
|
|
|
6
6
|
export const applyEvents = element => {
|
|
@@ -51,9 +51,20 @@ export const throughUpdatedExec = (element, options) => {
|
|
|
51
51
|
return changes
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
export const throughInitialDefine = element => {
|
|
54
|
+
export const throughInitialDefine = (element, options) => {
|
|
55
55
|
const { define } = element
|
|
56
|
-
|
|
56
|
+
let obj = {}
|
|
57
|
+
|
|
58
|
+
if (isObject(define)) {
|
|
59
|
+
obj = { ...define }
|
|
60
|
+
}
|
|
61
|
+
if (isObject(options.define)) {
|
|
62
|
+
// console.log('==============')
|
|
63
|
+
// console.log(options.define)
|
|
64
|
+
obj = { ...obj, ...options.define }
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
for (const param in obj) {
|
|
57
68
|
let prop = element[param]
|
|
58
69
|
|
|
59
70
|
if (isFunction(prop) && !isMethod(param)) {
|
|
@@ -62,19 +73,28 @@ export const throughInitialDefine = element => {
|
|
|
62
73
|
}
|
|
63
74
|
|
|
64
75
|
element.__cached[param] = prop
|
|
65
|
-
element[param] =
|
|
76
|
+
element[param] = obj[param](prop, element, element.state)
|
|
66
77
|
}
|
|
67
78
|
return element
|
|
68
79
|
}
|
|
69
80
|
|
|
70
|
-
export const throughUpdatedDefine = element => {
|
|
81
|
+
export const throughUpdatedDefine = (element, options) => {
|
|
71
82
|
const { define, __exec } = element
|
|
72
83
|
const changes = {}
|
|
73
|
-
|
|
84
|
+
let obj = {}
|
|
85
|
+
|
|
86
|
+
if (isObject(define)) {
|
|
87
|
+
obj = { ...define }
|
|
88
|
+
}
|
|
89
|
+
if (isObject(options.define)) {
|
|
90
|
+
obj = { ...obj, ...options.define }
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
for (const param in obj) {
|
|
74
94
|
const execParam = __exec[param]
|
|
75
95
|
if (execParam) element.__cached[param] = execParam(element, element.state)
|
|
76
96
|
const cached = exec(element.__cached[param], element)
|
|
77
|
-
element[param] =
|
|
97
|
+
element[param] = obj[param](cached, element, element.state)
|
|
78
98
|
}
|
|
79
99
|
return changes
|
|
80
100
|
}
|
|
@@ -24,7 +24,7 @@ export const classify = (obj, element) => {
|
|
|
24
24
|
return className
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
export default (params, element, node) => {
|
|
27
|
+
export default (params, element, node, live) => {
|
|
28
28
|
if (!params) return
|
|
29
29
|
const { key, __className } = element
|
|
30
30
|
if (params === true) params = element.class = { key }
|
package/src/element/node.js
CHANGED
|
@@ -61,7 +61,7 @@ const createNode = (element, options) => {
|
|
|
61
61
|
// iterate through all given params
|
|
62
62
|
if (element.tag !== 'string' || element.tag !== 'fragment') {
|
|
63
63
|
// iterate through define
|
|
64
|
-
|
|
64
|
+
throughInitialDefine(element, options)
|
|
65
65
|
|
|
66
66
|
// iterate through exec
|
|
67
67
|
throughInitialExec(element)
|
|
@@ -76,10 +76,18 @@ const createNode = (element, options) => {
|
|
|
76
76
|
|
|
77
77
|
const hasDefined = element.define && element.define[param]
|
|
78
78
|
const ourParam = registry[param]
|
|
79
|
+
const hasOptionsDefine = options.define && options.define[param]
|
|
79
80
|
|
|
80
|
-
if (
|
|
81
|
+
if (options.define) {
|
|
82
|
+
// console.group('create')
|
|
83
|
+
// console.log(param, options.define)
|
|
84
|
+
// console.log(prop, hasOptionsDefine)
|
|
85
|
+
// console.groupEnd('create')
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (ourParam && !hasOptionsDefine) { // Check if param is in our method registry
|
|
81
89
|
if (isFunction(ourParam)) ourParam(prop, element, node, options)
|
|
82
|
-
} else if (element[param] && !hasDefined) {
|
|
90
|
+
} else if (element[param] && !hasDefined&& !hasOptionsDefine) {
|
|
83
91
|
create(prop, element, param, options) // Create element
|
|
84
92
|
}
|
|
85
93
|
}
|
package/src/element/update.js
CHANGED
|
@@ -58,7 +58,7 @@ const update = function (params = {}, options = UPDATE_DEFAULT_OPTIONS) {
|
|
|
58
58
|
|
|
59
59
|
const overwriteChanges = overwrite(element, params, UPDATE_DEFAULT_OPTIONS)
|
|
60
60
|
const execChanges = throughUpdatedExec(element, UPDATE_DEFAULT_OPTIONS)
|
|
61
|
-
const definedChanges = throughUpdatedDefine(element)
|
|
61
|
+
const definedChanges = throughUpdatedDefine(element, options)
|
|
62
62
|
|
|
63
63
|
if (options.stackChanges && element.__stackChanges) {
|
|
64
64
|
const stackChanges = merge(definedChanges, merge(execChanges, overwriteChanges))
|
|
@@ -90,11 +90,20 @@ const update = function (params = {}, options = UPDATE_DEFAULT_OPTIONS) {
|
|
|
90
90
|
const hasDefined = define && define[param]
|
|
91
91
|
const ourParam = registry[param]
|
|
92
92
|
|
|
93
|
-
|
|
93
|
+
const hasOptionsDefine = options.define && options.define[param]
|
|
94
|
+
|
|
95
|
+
if (options.define) {
|
|
96
|
+
console.group('update')
|
|
97
|
+
console.log(param, options.define)
|
|
98
|
+
console.log(prop, hasOptionsDefine)
|
|
99
|
+
console.groupEnd('update')
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (ourParam && !hasOptionsDefine) {
|
|
94
103
|
if (isFunction(ourParam)) {
|
|
95
104
|
ourParam(prop, element, node)
|
|
96
105
|
}
|
|
97
|
-
} else if (prop && isObject(prop) && !hasDefined) {
|
|
106
|
+
} else if (prop && isObject(prop) && !hasDefined && !hasOptionsDefine) {
|
|
98
107
|
if (!options.preventRecursive) {
|
|
99
108
|
const childUpdateCall = () => update.call(prop, params[prop], {
|
|
100
109
|
...options,
|
package/src/utils/object.js
CHANGED
|
@@ -169,7 +169,7 @@ export const overwrite = (element, params, options) => {
|
|
|
169
169
|
const elementProp = element[e]
|
|
170
170
|
const paramsProp = params[e]
|
|
171
171
|
|
|
172
|
-
if (paramsProp) {
|
|
172
|
+
if (paramsProp !== undefined) {
|
|
173
173
|
element.__cached[e] = changes[e] = elementProp
|
|
174
174
|
element[e] = paramsProp
|
|
175
175
|
}
|