domql 1.4.8 → 1.4.9
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/src/element/create.js +4 -21
- package/src/element/proto.js +1 -29
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.9",
|
|
7
7
|
"repository": "https://github.com/rackai/domql",
|
|
8
8
|
"publishConfig": {
|
|
9
9
|
"registry": "https://registry.npmjs.org"
|
package/src/element/create.js
CHANGED
|
@@ -44,13 +44,9 @@ const create = (element, parent, key, options = {}) => {
|
|
|
44
44
|
const assignedKey = element.key || key || createID.next().value
|
|
45
45
|
|
|
46
46
|
// if PARENT is not given
|
|
47
|
-
// if (parent === null) parent = root
|
|
48
|
-
// if (parent === undefined) parent = root
|
|
49
47
|
if (!parent) parent = root
|
|
50
48
|
if (isNode(parent)) parent = root[`${key}_parent`] = { node: parent }
|
|
51
49
|
|
|
52
|
-
// if (assignedKey === 'all') debugger
|
|
53
|
-
|
|
54
50
|
// if element is STRING
|
|
55
51
|
if (isString(element) || isNumber(element)) {
|
|
56
52
|
element = {
|
|
@@ -61,6 +57,7 @@ const create = (element, parent, key, options = {}) => {
|
|
|
61
57
|
}
|
|
62
58
|
|
|
63
59
|
// create PROTOtypal inheritance
|
|
60
|
+
|
|
64
61
|
applyPrototype(element, parent, options)
|
|
65
62
|
|
|
66
63
|
if (Object.keys(options).length) {
|
|
@@ -71,9 +68,6 @@ const create = (element, parent, key, options = {}) => {
|
|
|
71
68
|
// enable STATE
|
|
72
69
|
element.state = createState(element, parent)
|
|
73
70
|
|
|
74
|
-
// console.groupCollapsed('Create:', assignedKey)
|
|
75
|
-
// console.log(element)
|
|
76
|
-
|
|
77
71
|
// create and assign a KEY
|
|
78
72
|
element.key = assignedKey
|
|
79
73
|
|
|
@@ -87,16 +81,14 @@ const create = (element, parent, key, options = {}) => {
|
|
|
87
81
|
}
|
|
88
82
|
}
|
|
89
83
|
|
|
90
|
-
// set the PATH
|
|
84
|
+
// set the PATH array
|
|
91
85
|
if (ENV === 'test' || ENV === 'development') {
|
|
92
86
|
if (!parent.path) parent.path = []
|
|
93
87
|
element.path = parent.path.concat(assignedKey)
|
|
94
88
|
}
|
|
95
89
|
|
|
96
|
-
// if it already HAS
|
|
97
|
-
if (element.node) { // TODO: check on if
|
|
98
|
-
// console.log('hasNode!')
|
|
99
|
-
// console.groupEnd('Create:')
|
|
90
|
+
// if it already HAS a NODE
|
|
91
|
+
if (element.node && !element.__ifFalsy) { // TODO: check on if
|
|
100
92
|
return assignNode(element, parent, assignedKey)
|
|
101
93
|
}
|
|
102
94
|
|
|
@@ -139,15 +131,6 @@ const create = (element, parent, key, options = {}) => {
|
|
|
139
131
|
// generate a CLASS name
|
|
140
132
|
assignClass(element)
|
|
141
133
|
|
|
142
|
-
// console.log('cache.props:')
|
|
143
|
-
// console.log(cache.props)
|
|
144
|
-
// console.log('applied props:')
|
|
145
|
-
// console.log(element.props)
|
|
146
|
-
// console.log('element:')
|
|
147
|
-
// console.log(element)
|
|
148
|
-
// console.groupEnd('Create:')
|
|
149
|
-
|
|
150
|
-
|
|
151
134
|
// console.group('create')
|
|
152
135
|
// console.log(element.path)
|
|
153
136
|
// console.log(element)
|
package/src/element/proto.js
CHANGED
|
@@ -12,26 +12,10 @@ export const applyPrototype = (element, parent, options = {}) => {
|
|
|
12
12
|
if (isFunction(element)) element = exec(element, parent)
|
|
13
13
|
|
|
14
14
|
const { proto } = element
|
|
15
|
-
|
|
16
|
-
// merge if proto is array
|
|
17
|
-
// const proto = mergeAndCloneIfArray(element.proto, v => {
|
|
18
|
-
// if (v.props) cache.props.push(v.props)
|
|
19
|
-
// console.log('v.propsIN_PROTO:')
|
|
20
|
-
// console.log(v.props)
|
|
21
|
-
// })
|
|
22
|
-
|
|
23
|
-
// console.log(proto)
|
|
24
15
|
const protoStack = getProtoStack(proto)
|
|
25
16
|
|
|
26
17
|
if (ENV !== 'test' || ENV !== 'development') delete element.proto
|
|
27
18
|
|
|
28
|
-
// console.log(parent.childProto)
|
|
29
|
-
|
|
30
|
-
// console.log(element)
|
|
31
|
-
// console.log(proto)
|
|
32
|
-
// console.log(protoStack)
|
|
33
|
-
// debugger
|
|
34
|
-
|
|
35
19
|
let childProtoStack = []
|
|
36
20
|
if (parent) {
|
|
37
21
|
// Assign parent attr to the element
|
|
@@ -41,18 +25,9 @@ export const applyPrototype = (element, parent, options = {}) => {
|
|
|
41
25
|
}
|
|
42
26
|
}
|
|
43
27
|
|
|
44
|
-
// console.log(proto, parent && parent.childProto)
|
|
45
|
-
// console.log(protoStack, childProtoStack)
|
|
46
|
-
|
|
47
28
|
const protoLength = protoStack.length
|
|
48
29
|
const childProtoLength = childProtoStack.length
|
|
49
30
|
|
|
50
|
-
// console.group('proto')
|
|
51
|
-
// console.log(protoLength)
|
|
52
|
-
// console.log(childProtoLength)
|
|
53
|
-
// console.log(element)
|
|
54
|
-
// console.groupEnd('proto')
|
|
55
|
-
|
|
56
31
|
let stack = []
|
|
57
32
|
if (protoLength && childProtoLength) {
|
|
58
33
|
stack = jointStacks(protoStack, childProtoStack)
|
|
@@ -73,11 +48,8 @@ export const applyPrototype = (element, parent, options = {}) => {
|
|
|
73
48
|
const component = exec(element.component || mergedProto.component, element)
|
|
74
49
|
if (component && options.components && options.components[component]) {
|
|
75
50
|
const componentProto = cloneAndMergeArrayProto(getProtoStack(options.components[component]))
|
|
76
|
-
mergedProto = deepMergeProto(
|
|
51
|
+
mergedProto = deepMergeProto(componentProto, mergedProto)
|
|
77
52
|
}
|
|
78
53
|
|
|
79
|
-
// console.log(mergedProto)
|
|
80
54
|
return deepMergeProto(element, mergedProto)
|
|
81
|
-
|
|
82
|
-
// final merging with prototype
|
|
83
55
|
}
|