domql 1.5.9 → 1.5.11

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.5.9",
6
+ "version": "1.5.11",
7
7
  "repository": "https://github.com/rackai/domql",
8
8
  "publishConfig": {
9
9
  "registry": "https://registry.npmjs.org"
@@ -32,6 +32,17 @@ const create = (element, parent, key, options = {}) => {
32
32
  element = { extend: element }
33
33
  }
34
34
 
35
+ // define KEY
36
+ const assignedKey = element.key || key || createID.next().value
37
+
38
+ const firstKeyChar = assignedKey.slice(0, 1)
39
+ if (!element.extend && !element.props && /^[A-Z]*$/.test(firstKeyChar)) {
40
+ element = {
41
+ extend: assignedKey,
42
+ props: element
43
+ }
44
+ }
45
+
35
46
  if (options.components) {
36
47
  const { components } = options
37
48
  const { extend, component } = element
@@ -40,9 +51,6 @@ const create = (element, parent, key, options = {}) => {
40
51
  else console.warn(extend, 'is not in library', components, element)
41
52
  }
42
53
 
43
- // define KEY
44
- const assignedKey = element.key || key || createID.next().value
45
-
46
54
  // if PARENT is not given
47
55
  if (!parent) parent = root
48
56
  if (isNode(parent)) parent = root[`${key}_parent`] = { key: ':root', node: parent }
@@ -56,6 +64,10 @@ const create = (element, parent, key, options = {}) => {
56
64
  }
57
65
  }
58
66
 
67
+ // assign context
68
+ if (options.context && !root.context) root.context = options.context
69
+ element.context = root.context
70
+
59
71
  // create EXTEND inheritance
60
72
  applyExtend(element, parent, options)
61
73
 
@@ -117,9 +129,8 @@ const create = (element, parent, key, options = {}) => {
117
129
  // enable CHANGES storing
118
130
  if (!element.__changes) element.__changes = []
119
131
 
120
- // assign context
121
- if (options.context && !root.context) root.context = options.context
122
- element.context = root.context
132
+ // enable CHANGES storing
133
+ if (!element.__children) element.__children = []
123
134
 
124
135
  // Add _root element property
125
136
  const hasRoot = parent.parent && parent.parent.key === ':root'
@@ -154,6 +165,8 @@ const create = (element, parent, key, options = {}) => {
154
165
  on.render(element.on.render, element, element.state)
155
166
  }
156
167
 
168
+ if (parent.__children) parent.__children.push(element.key)
169
+
157
170
  return element
158
171
  }
159
172
 
@@ -11,7 +11,8 @@ export const lookup = function (key) {
11
11
  const element = this
12
12
  let { parent } = element
13
13
 
14
- while (parent.key !== key) {
14
+ while (parent.key !== key){
15
+ if (parent[key]) return parent[key]
15
16
  parent = parent.parent
16
17
  if (!parent) return
17
18
  }
@@ -38,6 +38,7 @@ export default {
38
38
  __props: {},
39
39
  __extend: {},
40
40
  __ifFragment: {},
41
+ __children: {},
41
42
  __ifFalsy: {},
42
43
  __text: {},
43
44
  key: {},
@@ -8,6 +8,7 @@ const initProps = (element, parent) => {
8
8
 
9
9
  const isMatch = isString(props) && props.indexOf('match') > -1
10
10
  const matchParent = parent.props && parent.props[element.key]
11
+ const matchParentChild = parent.props && parent.props.childProps
11
12
 
12
13
  const objectizeStringProperty = propValue => {
13
14
  if (isString(propValue)) return { inheritedString: propValue }
@@ -15,6 +16,7 @@ const initProps = (element, parent) => {
15
16
  }
16
17
 
17
18
  if (matchParent && props !== 'match') propsStack.push(matchParent)
19
+ if (matchParentChild) propsStack.push(matchParentChild)
18
20
 
19
21
  if (isObject(props)) {
20
22
  propsStack.push(props)