domql 1.5.30 → 1.5.32

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.30",
6
+ "version": "1.5.32",
7
7
  "repository": "https://github.com/rackai/domql",
8
8
  "publishConfig": {
9
9
  "registry": "https://registry.npmjs.org"
@@ -6,19 +6,8 @@ import { classList } from '../../src/element/mixins'
6
6
  import createEmotion from '@emotion/css/create-instance'
7
7
  const ENV = process.env.NODE_ENV
8
8
 
9
- export const initEmotion = (container, options) => {
10
- const {
11
- flush,
12
- hydrate,
13
- cx,
14
- merge,
15
- getRegisteredStyles,
16
- injectGlobal,
17
- keyframes,
18
- css,
19
- sheet,
20
- cache
21
- } = createEmotion({ key: 'smbls', container })
9
+ export const initDOMQLEmotion = (emotion, options) => {
10
+ if (!emotion) emotion = createEmotion(options || { key: 'smbls'})
22
11
 
23
12
  const style = (params, element, node) => {
24
13
  const execPareams = exec(params, element)
@@ -46,7 +35,7 @@ export const initEmotion = (container, options) => {
46
35
  const isEqual = isEqualDeep(__class[key], prop)
47
36
  if (!isEqual) {
48
37
  if ((ENV === 'test' || ENV === 'development') && isObject(prop)) prop.label = key || element.key
49
- const CSSed = css(prop)
38
+ const CSSed = emotion.css(prop)
50
39
  __class[key] = prop
51
40
  __classNames[key] = CSSed
52
41
  }
@@ -61,5 +50,3 @@ export const initEmotion = (container, options) => {
61
50
  overwrite: true
62
51
  })
63
52
  }
64
-
65
- initEmotion()
@@ -11,7 +11,7 @@ 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
- const { extend } = element
14
+ let { extend } = element
15
15
  if (isString(extend)) extend = options.components[extend]
16
16
  const extendStack = getExtendStack(extend)
17
17
 
@@ -48,6 +48,7 @@ export default {
48
48
  __className: {},
49
49
  __classNames: {},
50
50
  __attr: {},
51
+ __currentSnapshot: {},
51
52
  key: {},
52
53
  tag: {},
53
54
  parent: {},
@@ -1,26 +1,41 @@
1
1
  'use strict'
2
2
 
3
- import { overwrite, isFunction, isObject, isString, isNumber, isEqualDeep } from '../utils'
3
+ import { overwrite, isFunction, isObject, isString, isNumber, createSnapshotId, merge } from '../utils'
4
4
  import { registry } from './mixins'
5
- import * as on from '../event/on'
5
+ import { on } from '../event'
6
6
  import { isMethod } from './methods'
7
7
  import { throughUpdatedDefine, throughUpdatedExec } from './iterate'
8
- import { merge } from '../utils/object'
9
8
  import { appendNode } from './assign'
10
- import { createNode } from '.'
9
+ import { createNode } from './node'
11
10
  import { updateProps } from './props'
12
- import createState from './state'
11
+
12
+ const snapshot = {
13
+ snapshotId: createSnapshotId()
14
+ }
13
15
 
14
16
  const UPDATE_DEFAULT_OPTIONS = {
15
17
  stackChanges: false,
16
18
  cleanExec: true,
17
- preventRecursive: false
19
+ preventRecursive: false,
20
+ currentSnapshot: false,
21
+ calleeElement: false
18
22
  }
19
23
 
20
24
  const update = function (params = {}, options = UPDATE_DEFAULT_OPTIONS) {
21
25
  const element = this
22
26
  const { define, parent, node } = element
23
27
 
28
+ const { currentSnapshot, calleeElement } = options
29
+ if (!calleeElement) {
30
+ element.__currentSnapshot = snapshot.snapshotId.next().value
31
+ }
32
+ const snapshotOnCallee = element.__currentSnapshot || calleeElement && calleeElement.__currentSnapshot
33
+ if (snapshotOnCallee && currentSnapshot < snapshotOnCallee) {
34
+ // console.log(calleeElement)
35
+ // console.log(currentSnapshot, snapshotOnCallee, 'cancelling')
36
+ // return
37
+ }
38
+
24
39
  if (isString(params) || isNumber(params)) {
25
40
  params = { text: params }
26
41
  }
@@ -44,22 +59,21 @@ const update = function (params = {}, options = UPDATE_DEFAULT_OPTIONS) {
44
59
  const overwriteChanges = overwrite(element, params, UPDATE_DEFAULT_OPTIONS)
45
60
  const execChanges = throughUpdatedExec(element, UPDATE_DEFAULT_OPTIONS)
46
61
  const definedChanges = throughUpdatedDefine(element)
47
- // console.log(execChanges)
48
- // console.log(definedChanges)
49
62
 
50
63
  if (options.stackChanges && element.__stackChanges) {
51
64
  const stackChanges = merge(definedChanges, merge(execChanges, overwriteChanges))
52
65
  element.__stackChanges.push(stackChanges)
53
66
  }
54
67
 
55
- if (element.__ifFalsy) return element
68
+ if (element.__ifFalsy) return false
56
69
  if (!node) {
57
70
  // return createNode(element, options)
58
71
  return
59
72
  }
60
73
 
61
74
  if (element.on && isFunction(element.on.initUpdate) && !options.ignoreInitUpdate) {
62
- on.initUpdate(element.on.initUpdate, element, element.state)
75
+ const whatinitreturns = on.initUpdate(element.on.initUpdate, element, element.state)
76
+ if (whatinitreturns === false) return
63
77
  }
64
78
 
65
79
  for (const param in element) {
@@ -78,20 +92,23 @@ const update = function (params = {}, options = UPDATE_DEFAULT_OPTIONS) {
78
92
 
79
93
  if (ourParam) {
80
94
  if (isFunction(ourParam)) {
81
- // console.log(param)
82
95
  ourParam(prop, element, node)
83
96
  }
84
97
  } else if (prop && isObject(prop) && !hasDefined) {
85
98
  if (!options.preventRecursive) {
86
- const callChildUpdate = () => update.call(prop, params[prop], options)
99
+ const childUpdateCall = () => update.call(prop, params[prop], {
100
+ ...options,
101
+ currentSnapshot: snapshotOnCallee,
102
+ calleeElement: element
103
+ })
87
104
  if (element.props.lazyLoad || options.lazyLoad) {
88
- window.requestAnimationFrame(() => callChildUpdate())
89
- } else callChildUpdate()
105
+ window.requestAnimationFrame(() => childUpdateCall())
106
+ } else childUpdateCall()
90
107
  }
91
108
  }
92
109
  }
93
110
 
94
- if (element.on && isFunction(element.on.update)) {
111
+ if (!options.preventUpdate && element.on && isFunction(element.on.update)) {
95
112
  on.update(element.on.update, element, element.state)
96
113
  }
97
114
  }
package/src/utils/node.js CHANGED
@@ -2,9 +2,11 @@
2
2
 
3
3
  export const cleanWithNode = extend => delete extend.node && extend
4
4
 
5
- export const createID = (function * () {
5
+ export const createSnapshotId = function * () {
6
6
  let index = 1
7
7
  while (index < index + 1) {
8
8
  yield index++
9
9
  }
10
- }())
10
+ }
11
+
12
+ export const createID = (createSnapshotId())
package/src/element/id.js DELETED
@@ -1,10 +0,0 @@
1
- 'use strict'
2
-
3
- const createID = function * () {
4
- let index = 1
5
- while (index < index + 1) {
6
- yield index++
7
- }
8
- }
9
-
10
- export default createID()