domql 1.5.71 → 1.5.73

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": "symbo.ls",
6
- "version": "1.5.71",
6
+ "version": "1.5.73",
7
7
  "repository": "https://github.com/domql/domql",
8
8
  "publishConfig": {
9
9
  "registry": "https://registry.npmjs.org"
@@ -15,6 +15,7 @@ import { isObject, isFunction, isNumber, isString, createID, isNode, exec } from
15
15
  import { remove, lookup, setProps, log, keys, parse, parseDeep, spotByPath, nextElement, previousElement, isMethod } from './methods'
16
16
  import cacheNode from './cache'
17
17
  import { registry } from './mixins'
18
+ import { throughInitialExec } from './iterate'
18
19
  import OPTIONS from './options'
19
20
  // import { overwrite, clone, fillTheRest } from '../utils'
20
21
 
@@ -93,8 +94,13 @@ const create = (element, parent, key, options = OPTIONS.create || {}) => {
93
94
  }
94
95
  }
95
96
 
96
- if (options.components) {
97
- const { components } = options
97
+ // assign context
98
+ if (options.context && !root.context) root.context = options.context
99
+ element.context = root.context
100
+ const { context } = element
101
+
102
+ if (context.components) {
103
+ const { components } = context
98
104
  const { extend } = element
99
105
  const execExtend = exec(extend, element)
100
106
  if (isString(execExtend)) {
@@ -111,8 +117,17 @@ const create = (element, parent, key, options = OPTIONS.create || {}) => {
111
117
 
112
118
  // Only resolve extends, skip everything else
113
119
  if (options.onlyResolveExtends) {
120
+ // parent.appendChild = () => {}
121
+ // element.node = { setAttribute(){} }
122
+
114
123
  applyExtend(element, parent, options)
115
- // if (!element.__attr) element.__attr = {}
124
+
125
+ if (!element.__exec) element.__exec = {}
126
+ if (!element.__attr) element.__attr = {}
127
+ if (!element.__ifFalsy) createProps(element, parent)
128
+ element.key = assignedKey
129
+
130
+ throughInitialExec(element)
116
131
 
117
132
  for (const param in element) {
118
133
  const prop = element[param]
@@ -122,20 +137,22 @@ const create = (element, parent, key, options = OPTIONS.create || {}) => {
122
137
  const ourParam = registry[param]
123
138
  const hasOptionsDefine = options.define && options.define[param]
124
139
  if (ourParam && !hasOptionsDefine) {
125
- continue
140
+ continue // if (isFunction(ourParam)) ourParam(prop, element, element.node, options)
126
141
  } else if (element[param] && !hasDefined && !hasOptionsDefine) {
127
142
  create(exec(prop, element), element, param, options)
128
143
  }
129
144
  }
130
145
 
131
146
  // createNode(element, options)
147
+ delete element.parent
148
+ delete element.__element
149
+ delete element.__props
150
+ delete element.props.__element
151
+ delete element.props.update
152
+ delete element.update
132
153
  return element
133
154
  }
134
155
 
135
- // assign context
136
- if (options.context && !root.context) root.context = options.context
137
- element.context = root.context
138
-
139
156
  // create EXTEND inheritance
140
157
  applyExtend(element, parent, options)
141
158
 
@@ -170,8 +187,8 @@ const create = (element, parent, key, options = OPTIONS.create || {}) => {
170
187
  if (!element.__children) element.__children = []
171
188
 
172
189
  // Add _root element property
173
- const hasRoot = parent.parent && parent.parent.key === ':root'
174
- if (!element.__root) element.__root = hasRoot ? parent : parent.__root
190
+ const hasRoot = parent && parent.key === ':root'
191
+ if (!element.__root) element.__root = hasRoot ? element : parent.__root
175
192
 
176
193
  // set the PATH array
177
194
  if (ENV === 'test' || ENV === 'development') {
@@ -11,8 +11,10 @@ const ENV = process.env.NODE_ENV
11
11
  export const applyExtend = (element, parent, options = {}) => {
12
12
  if (isFunction(element)) element = exec(element, parent)
13
13
 
14
- let { extend, props } = element
15
- if (isString(extend)) extend = options.components[extend]
14
+ let { extend, props, context } = element
15
+ const COMPONENTS = context.components || options.components
16
+
17
+ if (isString(extend)) extend = COMPONENTS[extend]
16
18
  const extendStack = getExtendStack(extend)
17
19
 
18
20
  if (ENV !== 'test' || ENV !== 'development') delete element.extend
@@ -55,8 +57,8 @@ export const applyExtend = (element, parent, options = {}) => {
55
57
  let mergedExtend = cloneAndMergeArrayExtend(stack)
56
58
 
57
59
  const component = exec(element.component || mergedExtend.component, element)
58
- if (component && options.components && options.components[component]) {
59
- const componentExtend = cloneAndMergeArrayExtend(getExtendStack(options.components[component]))
60
+ if (component && COMPONENTS && COMPONENTS[component]) {
61
+ const componentExtend = cloneAndMergeArrayExtend(getExtendStack(COMPONENTS[component]))
60
62
  mergedExtend = deepMergeExtend(componentExtend, mergedExtend)
61
63
  }
62
64
 
@@ -75,18 +75,11 @@ export const createNode = (element, options) => {
75
75
  if (isMethod(param) || isObject(registry[param]) || prop === undefined) continue
76
76
 
77
77
  const hasDefined = element.define && element.define[param]
78
- const ourParam = registry[param]
78
+ const DOMQLProperty = registry[param]
79
79
  const hasOptionsDefine = options.define && options.define[param]
80
80
 
81
- if (options.define) {
82
- // console.group('create')
83
- // console.log(param, options.define)
84
- // console.log(prop, hasOptionsDefine)
85
- // console.groupEnd('create')
86
- }
87
-
88
- if (ourParam && !hasOptionsDefine) { // Check if param is in our method registry
89
- if (isFunction(ourParam)) ourParam(prop, element, node, options)
81
+ if (DOMQLProperty && !hasOptionsDefine) { // Check if param is in our method registry
82
+ if (isFunction(DOMQLProperty)) DOMQLProperty(prop, element, node, options)
90
83
  } else if (element[param] && !hasDefined && !hasOptionsDefine) {
91
84
  create(exec(prop, element), element, param, options) // Create element
92
85
  }