domql 1.6.16 → 1.6.17

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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "domql",
3
3
  "description": "DOM rendering Javascript framework at early stage.",
4
- "version": "1.6.16",
4
+ "version": "1.6.17",
5
5
  "repository": "https://github.com/domql/domql",
6
6
  "publishConfig": {
7
7
  "registry": "https://registry.npmjs.org"
@@ -34,7 +34,10 @@ const ENV = process.env.NODE_ENV
34
34
  * Creating a domQL element using passed parameters
35
35
  */
36
36
  const create = (element, parent, key, options = OPTIONS.create || {}) => {
37
- if (options && !OPTIONS.create) OPTIONS.create = options
37
+ if (options && !OPTIONS.create) {
38
+ OPTIONS.create = options
39
+ OPTIONS.create.context = element.context || options.context
40
+ }
38
41
 
39
42
  // if ELEMENT is not given
40
43
  if (element === undefined) {
@@ -13,9 +13,10 @@ export const applyExtend = (element, parent, options = {}) => {
13
13
  if (isFunction(element)) element = exec(element, parent)
14
14
 
15
15
  let { extend, props, context, __ref } = element
16
+
16
17
  const COMPONENTS = (context && context.components) || options.components
18
+ if (isString(extend) && COMPONENTS) extend = COMPONENTS[extend]
17
19
 
18
- if (isString(extend)) extend = COMPONENTS[extend]
19
20
  const extendStack = getExtendStack(extend)
20
21
 
21
22
  if (ENV !== 'test' || ENV !== 'development') delete element.extend
@@ -13,6 +13,7 @@ import create from './create'
13
13
  import { throughUpdatedDefine, throughUpdatedExec } from './iterate'
14
14
  import { registry } from './mixins'
15
15
  import { applyParam } from './applyParam'
16
+ import OPTIONS from './options'
16
17
 
17
18
  const snapshot = {
18
19
  snapshotId: createSnapshotId
@@ -30,8 +31,10 @@ const UPDATE_DEFAULT_OPTIONS = {
30
31
  const update = function (params = {}, options = UPDATE_DEFAULT_OPTIONS) {
31
32
  const element = this
32
33
  const { parent, node, key } = element
34
+ const { excludes, preventInheritAtCurrentState } = options
33
35
 
34
- if (!options.excludes) merge(options, UPDATE_DEFAULT_OPTIONS)
36
+ if (preventInheritAtCurrentState && preventInheritAtCurrentState.__element === element) return
37
+ if (!excludes) merge(options, UPDATE_DEFAULT_OPTIONS)
35
38
 
36
39
  let __ref = element.__ref
37
40
  if (!__ref) __ref = element.__ref = {}
@@ -43,7 +46,7 @@ const update = function (params = {}, options = UPDATE_DEFAULT_OPTIONS) {
43
46
  params = { text: params }
44
47
  }
45
48
 
46
- const ifFails = checkIfOnUpdate(element, options)
49
+ const ifFails = checkIfOnUpdate(element, parent, options,)
47
50
  if (ifFails) return
48
51
 
49
52
  const inheritState = inheritStateUpdates(element, options)
@@ -128,25 +131,25 @@ const captureSnapshot = (element, options) => {
128
131
  return [snapshotOnCallee, calleeElement]
129
132
  }
130
133
 
131
- const checkIfOnUpdate = (element, options) => {
134
+ const checkIfOnUpdate = (element, parent, options) => {
132
135
  if (!isFunction(element.if)) return
133
136
 
134
- const __ref = element.__ref
137
+ const ref = element.__ref
135
138
  const ifPassed = element.if(element, element.state)
136
- const itWasFalse = __ref.__if !== true
139
+ const itWasFalse = ref.__if !== true
137
140
 
138
141
  if (ifPassed) {
139
- __ref.__if = true
142
+ ref.__if = true
140
143
  if (itWasFalse) {
141
144
  delete element.__hash
142
145
  delete element.extend
143
- if (!__ref.__hasRootState) {
146
+ if (!ref.__hasRootState) {
144
147
  delete element.state
145
148
  }
146
- if (__ref.__state) {
147
- element.state = __ref.__state
149
+ if (ref.__state) {
150
+ element.state = ref.__state
148
151
  }
149
- const created = create(element, element.parent, element.key)
152
+ const created = create(element, parent, element.key, OPTIONS.create)
150
153
  if (!options.preventUpdate && element.on && isFunction(element.on.update)) {
151
154
  applyEvent(element.on.update, created, created.state)
152
155
  }
@@ -154,7 +157,7 @@ const checkIfOnUpdate = (element, options) => {
154
157
  }
155
158
  } else if (element.node && !ifPassed) {
156
159
  element.node.remove()
157
- delete __ref.__if
160
+ delete ref.__if
158
161
  }
159
162
  }
160
163