domql 1.3.4 → 1.4.2
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 -1
- package/packages/emotion/index.js +1 -0
- package/src/element/create.js +29 -1
- package/src/element/createNode.js +3 -3
- package/src/element/createProps.js +16 -6
- package/src/element/mixins/content.js +2 -2
- package/src/element/proto.js +6 -1
- package/src/element/set.js +4 -2
- package/src/utils/protoUtils.js +3 -6
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.
|
|
6
|
+
"version": "1.4.2",
|
|
7
7
|
"repository": "https://github.com/rackai/domql",
|
|
8
8
|
"publishConfig": {
|
|
9
9
|
"registry": "https://registry.npmjs.org"
|
package/src/element/create.js
CHANGED
|
@@ -14,6 +14,7 @@ import { assignClass } from './mixins/classList'
|
|
|
14
14
|
import { isFunction, isNumber, isString, createID, isNode } from '../utils'
|
|
15
15
|
import { remove, lookup, log, keys, parse, parseDeep } from './methods'
|
|
16
16
|
import cacheNode from './cache'
|
|
17
|
+
import { registry } from './mixins'
|
|
17
18
|
// import { overwrite, clone, fillTheRest } from '../utils'
|
|
18
19
|
|
|
19
20
|
const ENV = process.env.NODE_ENV
|
|
@@ -26,6 +27,33 @@ const create = (element, parent, key, options = {}) => {
|
|
|
26
27
|
if (element === undefined) element = {}
|
|
27
28
|
if (element === null) return
|
|
28
29
|
|
|
30
|
+
if (Object.keys(options).length) {
|
|
31
|
+
registry.defaultOptions = options
|
|
32
|
+
if (options.ignoreChildProto) delete options.ignoreChildProto
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// if element is proto
|
|
36
|
+
if (element.__hash) {
|
|
37
|
+
element = { proto: element }
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (options.components) {
|
|
41
|
+
const { components } = options
|
|
42
|
+
const { proto } = element
|
|
43
|
+
if (isString(proto))
|
|
44
|
+
if (components[proto]) element.proto = components[proto]
|
|
45
|
+
else console.warn(proto, 'is not in library', components, element)
|
|
46
|
+
|
|
47
|
+
// // if KEY is PROTO
|
|
48
|
+
// const k = element.key || key
|
|
49
|
+
// const keyIsProto = isString(k) && k.charAt(0) === k.charAt(0).toUpperCase()
|
|
50
|
+
// if (keyIsProto) component = key
|
|
51
|
+
// let { match, ...rest } = element
|
|
52
|
+
// if proto comes from library as string
|
|
53
|
+
// const fromLibrary = isString(match) ? components[match] : match
|
|
54
|
+
// if (fromLibrary) element = { proto: fromLibrary, ...rest }
|
|
55
|
+
}
|
|
56
|
+
|
|
29
57
|
// define KEY
|
|
30
58
|
const assignedKey = element.key || key || createID.next().value
|
|
31
59
|
|
|
@@ -128,7 +156,7 @@ const create = (element, parent, key, options = {}) => {
|
|
|
128
156
|
}
|
|
129
157
|
|
|
130
158
|
// CREATE a real NODE
|
|
131
|
-
createNode(element)
|
|
159
|
+
createNode(element, options)
|
|
132
160
|
|
|
133
161
|
// assign NODE
|
|
134
162
|
assignNode(element, parent, key)
|
|
@@ -28,7 +28,7 @@ const ENV = process.env.NODE_ENV
|
|
|
28
28
|
// }
|
|
29
29
|
// })
|
|
30
30
|
|
|
31
|
-
const createNode = (element) => {
|
|
31
|
+
const createNode = (element, options) => {
|
|
32
32
|
// create and assign a node
|
|
33
33
|
let { node, tag } = element
|
|
34
34
|
|
|
@@ -78,9 +78,9 @@ const createNode = (element) => {
|
|
|
78
78
|
const ourParam = registry[param]
|
|
79
79
|
|
|
80
80
|
if (ourParam) { // Check if param is in our method registry
|
|
81
|
-
if (isFunction(ourParam)) ourParam(prop, element, node)
|
|
81
|
+
if (isFunction(ourParam)) ourParam(prop, element, node, options)
|
|
82
82
|
} else if (element[param] && !hasDefined) {
|
|
83
|
-
create(prop, element, param) // Create element
|
|
83
|
+
create(prop, element, param, options) // Create element
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
86
|
}
|
|
@@ -1,15 +1,25 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
import { deepClone, deepMerge, exec, isArray } from '../utils'
|
|
3
|
+
import { deepClone, deepMerge, exec, isArray, isObject, isString } from '../utils'
|
|
4
4
|
|
|
5
5
|
const initProps = (element, parent) => {
|
|
6
|
+
const { props } = element
|
|
6
7
|
const propsStack = []
|
|
7
8
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
const hasMatch = isString(props) && props.indexOf('match') > -1
|
|
10
|
+
const matchParent = parent.props && parent.props[element.key]
|
|
11
|
+
|
|
12
|
+
if (isObject(props)) {
|
|
13
|
+
propsStack.push(props)
|
|
14
|
+
} else if (props === 'inherit') {
|
|
15
|
+
if (parent.props) propsStack.push(parent.props)
|
|
16
|
+
} else if (hasMatch) {
|
|
17
|
+
const hasArg = props.split(' ')
|
|
18
|
+
if (hasArg[1] && parent.props[hasArg[1]]) propsStack.push(parent.props[hasArg[1]])
|
|
19
|
+
else if (matchParent) propsStack.push(matchParent)
|
|
20
|
+
} else if (props) propsStack.push(props)
|
|
21
|
+
|
|
22
|
+
if (matchParent && props !== 'match') propsStack.push(matchParent)
|
|
13
23
|
|
|
14
24
|
if (isArray(element.__proto)) {
|
|
15
25
|
element.__proto.map(proto => {
|
|
@@ -6,12 +6,12 @@ import set from '../set'
|
|
|
6
6
|
* Appends anything as content
|
|
7
7
|
* an original one as a child
|
|
8
8
|
*/
|
|
9
|
-
export default (param, element, node) => {
|
|
9
|
+
export default (param, element, node, options) => {
|
|
10
10
|
if (param && element) {
|
|
11
11
|
if (param.__hash === element.content.__hash && element.content.update) {
|
|
12
12
|
element.content.update(param)
|
|
13
13
|
} else {
|
|
14
|
-
set.call(element, param)
|
|
14
|
+
set.call(element, param, options)
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
}
|
package/src/element/proto.js
CHANGED
|
@@ -54,7 +54,12 @@ export const applyPrototype = (element, parent, options = {}) => {
|
|
|
54
54
|
stack = protoStack
|
|
55
55
|
} else if (childProtoLength) {
|
|
56
56
|
stack = childProtoStack
|
|
57
|
-
} else return element
|
|
57
|
+
} else if (!options.proto) return element
|
|
58
|
+
|
|
59
|
+
if (options.proto) {
|
|
60
|
+
const defaultOptionsProto = getProtoStack(options.proto)
|
|
61
|
+
stack = [].concat(stack, defaultOptionsProto)
|
|
62
|
+
}
|
|
58
63
|
|
|
59
64
|
element.__proto = stack
|
|
60
65
|
const mergedProto = cloneAndMergeArrayProto(stack)
|
package/src/element/set.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
import create from './create'
|
|
4
|
+
import { registry } from './mixins'
|
|
4
5
|
|
|
5
6
|
const removeContentElement = (params, element) => {
|
|
6
7
|
if (params && element.content) {
|
|
@@ -18,7 +19,7 @@ const removeContentElement = (params, element) => {
|
|
|
18
19
|
}
|
|
19
20
|
}
|
|
20
21
|
|
|
21
|
-
const set = function (params,
|
|
22
|
+
const set = function (params, options) {
|
|
22
23
|
const element = this
|
|
23
24
|
|
|
24
25
|
removeContentElement(params, element)
|
|
@@ -27,7 +28,8 @@ const set = function (params, enter, leave) {
|
|
|
27
28
|
const { childProto } = params
|
|
28
29
|
if (!childProto && element.childProto) params.childProto = element.childProto
|
|
29
30
|
create(params, element, 'content', {
|
|
30
|
-
ignoreChildProto: true
|
|
31
|
+
ignoreChildProto: true,
|
|
32
|
+
...registry.defaultOptions
|
|
31
33
|
})
|
|
32
34
|
}
|
|
33
35
|
|
package/src/utils/protoUtils.js
CHANGED
|
@@ -19,16 +19,13 @@ export const setHashedProto = (proto, stack) => {
|
|
|
19
19
|
const hash = generateHash()
|
|
20
20
|
proto.__hash = hash
|
|
21
21
|
protoStackRegistry[hash] = stack
|
|
22
|
-
return
|
|
22
|
+
return stack
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
export const getProtoStackRegistry = (proto, stack) => {
|
|
26
|
-
if (proto.__hash)
|
|
26
|
+
if (proto.__hash)
|
|
27
27
|
return stack.concat(getHashedProto(proto))
|
|
28
|
-
|
|
29
|
-
setHashedProto(proto, stack)
|
|
30
|
-
}
|
|
31
|
-
return stack // .concat(hashedProto)
|
|
28
|
+
return setHashedProto(proto, stack) // stack .concat(hashedProto)
|
|
32
29
|
}
|
|
33
30
|
|
|
34
31
|
// stacking
|