domql 1.4.9 → 1.4.12
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
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "DOM rendering Javascript framework at early stage.",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "rackai",
|
|
6
|
-
"version": "1.4.
|
|
6
|
+
"version": "1.4.12",
|
|
7
7
|
"repository": "https://github.com/rackai/domql",
|
|
8
8
|
"publishConfig": {
|
|
9
9
|
"registry": "https://registry.npmjs.org"
|
|
@@ -1,50 +1,54 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
import DOM from '../../src'
|
|
4
|
-
import { isObjectLike, exec } from '../../src/utils'
|
|
4
|
+
import { isObjectLike, exec, isObject } from '../../src/utils'
|
|
5
5
|
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
|
-
const {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
9
|
+
export const initEmotion = (container, options) => {
|
|
10
|
+
const {
|
|
11
|
+
flush,
|
|
12
|
+
hydrate,
|
|
13
|
+
cx,
|
|
14
|
+
merge,
|
|
15
|
+
getRegisteredStyles,
|
|
16
|
+
injectGlobal,
|
|
17
|
+
keyframes,
|
|
18
|
+
css,
|
|
19
|
+
sheet,
|
|
20
|
+
cache
|
|
21
|
+
} = createEmotion({ key: 'smbls', container })
|
|
21
22
|
|
|
22
|
-
const style = (params, element, node) => {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
const style = (params, element, node) => {
|
|
24
|
+
const execPareams = exec(params, element)
|
|
25
|
+
if (params) {
|
|
26
|
+
if (isObjectLike(element.class)) element.class.style = execPareams
|
|
27
|
+
else element.class = { style: execPareams }
|
|
28
|
+
}
|
|
29
|
+
classf(element.class, element, node)
|
|
27
30
|
}
|
|
28
|
-
classf(element.class, element, node)
|
|
29
|
-
}
|
|
30
31
|
|
|
31
|
-
const classf = (params, element, node) => {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
32
|
+
const classf = (params, element, node) => {
|
|
33
|
+
if (isObjectLike(params)) {
|
|
34
|
+
const classObjHelper = {}
|
|
35
|
+
for (const key in params) {
|
|
36
|
+
const prop = exec(params[key], element)
|
|
37
|
+
if (!prop) continue
|
|
38
|
+
if ((ENV === 'test' || ENV === 'development') && isObject(prop)) prop.label = key || element.key
|
|
39
|
+
const CSSed = css(prop)
|
|
40
|
+
classObjHelper[key] = CSSed
|
|
41
|
+
}
|
|
42
|
+
classList(classObjHelper, element, node)
|
|
40
43
|
}
|
|
41
|
-
classList(classObjHelper, element, node)
|
|
42
44
|
}
|
|
45
|
+
|
|
46
|
+
DOM.define({
|
|
47
|
+
style,
|
|
48
|
+
class: classf
|
|
49
|
+
}, {
|
|
50
|
+
overwrite: true
|
|
51
|
+
})
|
|
43
52
|
}
|
|
44
53
|
|
|
45
|
-
|
|
46
|
-
style,
|
|
47
|
-
class: classf
|
|
48
|
-
}, {
|
|
49
|
-
overwrite: true
|
|
50
|
-
})
|
|
54
|
+
initEmotion()
|
package/src/element/create.js
CHANGED
|
@@ -12,7 +12,7 @@ import update from './update'
|
|
|
12
12
|
import * as on from '../event/on'
|
|
13
13
|
import { assignClass } from './mixins/classList'
|
|
14
14
|
import { isFunction, isNumber, isString, createID, isNode } from '../utils'
|
|
15
|
-
import { remove, lookup, log, keys, parse, parseDeep } from './methods'
|
|
15
|
+
import { remove, lookup, setProps, log, keys, parse, parseDeep } from './methods'
|
|
16
16
|
import cacheNode from './cache'
|
|
17
17
|
import { registry } from './mixins'
|
|
18
18
|
// import { overwrite, clone, fillTheRest } from '../utils'
|
|
@@ -96,6 +96,7 @@ const create = (element, parent, key, options = {}) => {
|
|
|
96
96
|
element.set = set
|
|
97
97
|
element.update = update
|
|
98
98
|
element.remove = remove
|
|
99
|
+
element.setProps = setProps
|
|
99
100
|
element.lookup = lookup
|
|
100
101
|
element.parse = parse
|
|
101
102
|
element.parseDeep = parseDeep
|
|
@@ -116,7 +117,7 @@ const create = (element, parent, key, options = {}) => {
|
|
|
116
117
|
// enable CHANGES storing
|
|
117
118
|
if (!element.__changes) element.__changes = []
|
|
118
119
|
|
|
119
|
-
//
|
|
120
|
+
// Add _root element property
|
|
120
121
|
const hasRoot = parent.parent && parent.parent.key === ':root'
|
|
121
122
|
if (!element.__root) element.__root = hasRoot ? parent : parent.__root
|
|
122
123
|
|
|
@@ -6,7 +6,7 @@ const initProps = (element, parent) => {
|
|
|
6
6
|
const { props } = element
|
|
7
7
|
const propsStack = []
|
|
8
8
|
|
|
9
|
-
const
|
|
9
|
+
const isMatch = isString(props) && props.indexOf('match') > -1
|
|
10
10
|
const matchParent = parent.props && parent.props[element.key]
|
|
11
11
|
|
|
12
12
|
const objectizeStringProperty = propValue => {
|
|
@@ -18,10 +18,12 @@ const initProps = (element, parent) => {
|
|
|
18
18
|
propsStack.push(props)
|
|
19
19
|
} else if (props === 'inherit') {
|
|
20
20
|
if (parent.props) propsStack.push(parent.props)
|
|
21
|
-
} else if (
|
|
21
|
+
} else if (isMatch) {
|
|
22
22
|
const hasArg = props.split(' ')
|
|
23
23
|
let matchParentValue
|
|
24
|
+
//console.log('hasArg', hasArg)
|
|
24
25
|
if (hasArg[1] && parent.props[hasArg[1]]) {
|
|
26
|
+
console.log('hasArg[1]', hasArg[1])
|
|
25
27
|
const secondArgasParentMatchProp = parent.props[hasArg[1]]
|
|
26
28
|
propsStack.push(
|
|
27
29
|
objectizeStringProperty(secondArgasParentMatchProp)
|
package/src/element/index.js
CHANGED
|
@@ -12,7 +12,7 @@ import update from './update'
|
|
|
12
12
|
import parse from './parse'
|
|
13
13
|
import set from './set'
|
|
14
14
|
|
|
15
|
-
import { lookup, remove, get, log, keys } from './methods'
|
|
15
|
+
import { lookup, remove, get, setProps, log, keys } from './methods'
|
|
16
16
|
|
|
17
17
|
export {
|
|
18
18
|
nodes,
|
|
@@ -27,6 +27,7 @@ export {
|
|
|
27
27
|
update,
|
|
28
28
|
parse,
|
|
29
29
|
lookup,
|
|
30
|
+
setProps,
|
|
30
31
|
set,
|
|
31
32
|
get,
|
|
32
33
|
log,
|
package/src/element/methods.js
CHANGED
|
@@ -33,6 +33,13 @@ export const set = function () {
|
|
|
33
33
|
export const update = function () {
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
+
export const setProps = function (param, options) {
|
|
37
|
+
const element = this
|
|
38
|
+
if (!param || !element.props) return
|
|
39
|
+
element.update({ props: param }, options)
|
|
40
|
+
return element.props
|
|
41
|
+
}
|
|
42
|
+
|
|
36
43
|
export const defineSetter = (element, key, get, set) =>
|
|
37
44
|
Object.defineProperty(element, key, { get, set })
|
|
38
45
|
|
|
@@ -90,6 +97,7 @@ export const isMethod = function (param) {
|
|
|
90
97
|
param === 'lookup' ||
|
|
91
98
|
param === 'keys' ||
|
|
92
99
|
param === 'parse' ||
|
|
100
|
+
param === 'setProps' ||
|
|
93
101
|
param === 'parseDeep' ||
|
|
94
102
|
param === 'if' ||
|
|
95
103
|
param === 'log'
|
package/src/element/update.js
CHANGED
|
@@ -77,7 +77,7 @@ const update = function (params = {}, options = UPDATE_DEFAULT_OPTIONS) {
|
|
|
77
77
|
// else console.log(element.path, '\n\n', stackChanges)
|
|
78
78
|
|
|
79
79
|
// console.log(element.key, element.__ifFalsy)
|
|
80
|
-
if (element.__ifFalsy
|
|
80
|
+
if (element.__ifFalsy) return element
|
|
81
81
|
if (!node) {
|
|
82
82
|
return
|
|
83
83
|
// return createNode(element, options)
|
|
@@ -101,12 +101,12 @@ const update = function (params = {}, options = UPDATE_DEFAULT_OPTIONS) {
|
|
|
101
101
|
const hasDefined = define && define[param]
|
|
102
102
|
const ourParam = registry[param]
|
|
103
103
|
|
|
104
|
-
|
|
104
|
+
if (options.preventContentUpdate && param === 'content') console.log(param)
|
|
105
105
|
|
|
106
106
|
if (ourParam) {
|
|
107
107
|
if (isFunction(ourParam)) ourParam(prop, element, node)
|
|
108
108
|
} else if (prop && isObject(prop) && !hasDefined) {
|
|
109
|
-
if (!options.
|
|
109
|
+
if (!options.preventRecursive) update.call(prop, params[prop], UPDATE_DEFAULT_OPTIONS)
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
112
|
|