domql 1.4.0 → 1.4.1
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.1",
|
|
7
7
|
"repository": "https://github.com/rackai/domql",
|
|
8
8
|
"publishConfig": {
|
|
9
9
|
"registry": "https://registry.npmjs.org"
|
package/src/element/create.js
CHANGED
|
@@ -32,6 +32,26 @@ const create = (element, parent, key, options = {}) => {
|
|
|
32
32
|
if (options.ignoreChildProto) delete options.ignoreChildProto
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
+
// if element is proto
|
|
36
|
+
if (element.__hash) {
|
|
37
|
+
element = { proto: element }
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// if KEY is PROTO
|
|
41
|
+
if (options.components) {
|
|
42
|
+
const { components } = options
|
|
43
|
+
|
|
44
|
+
const k = element.key || key
|
|
45
|
+
const keyIsProto = isString(k) && k.charAt(0) === k.charAt(0).toUpperCase()
|
|
46
|
+
let component
|
|
47
|
+
if (keyIsProto) component = key
|
|
48
|
+
|
|
49
|
+
// if proto comes from library as string
|
|
50
|
+
const fromLibrary = component || isString(element.proto) ? element.proto : element.component
|
|
51
|
+
const isInLibrary = components[fromLibrary]
|
|
52
|
+
if (isInLibrary) element = { proto: isInLibrary, props: element }
|
|
53
|
+
}
|
|
54
|
+
|
|
35
55
|
// define KEY
|
|
36
56
|
const assignedKey = element.key || key || createID.next().value
|
|
37
57
|
|
|
@@ -1,17 +1,25 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
import { deepClone, deepMerge, exec, isArray, isObject } 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
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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)
|
|
15
23
|
|
|
16
24
|
if (isArray(element.__proto)) {
|
|
17
25
|
element.__proto.map(proto => {
|
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
|