domql 1.5.24 → 1.5.26

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.24",
6
+ "version": "1.5.26",
7
7
  "repository": "https://github.com/rackai/domql",
8
8
  "publishConfig": {
9
9
  "registry": "https://registry.npmjs.org"
@@ -11,7 +11,7 @@ import createProps from './props'
11
11
  import update from './update'
12
12
  import * as on from '../event/on'
13
13
  import { assignClass } from './mixins/classList'
14
- import { isFunction, isNumber, isString, createID, isNode, exec } from '../utils'
14
+ import { isFunction, isNumber, isString, createID, isNode, exec, isArray } from '../utils'
15
15
  import { remove, lookup, setProps, log, keys, parse, parseDeep, spotByPath } from './methods'
16
16
  import cacheNode from './cache'
17
17
  import { registry } from './mixins'
@@ -66,7 +66,7 @@ const create = (element, parent, key, options = {}) => {
66
66
  if (isComponent(assignedKey)) {
67
67
  if (!extend && !childExtend && !props && !state || childProps) {
68
68
  element = {
69
- extend: assignedKey,
69
+ extend: assignedKey.split('_')[0],
70
70
  props: element
71
71
  }
72
72
  } else if (!extend || extend === true) {
@@ -32,7 +32,8 @@ export default (params, element, node) => {
32
32
  if (isObject(params)) params = classify(params, element)
33
33
  // TODO: fails on string
34
34
  const className = params.replace(/\s+/g, ' ').trim()
35
- if (className && className !== __className) node.classList = className
36
- element.__className = className
35
+ node.classList = className
36
+ // if (className && className !== __className) node.classList = className
37
+ // element.__className = className
37
38
  return className
38
39
  }
@@ -1,10 +1,9 @@
1
1
  'use strict'
2
2
 
3
- import { update } from '.'
4
3
  import { on } from '../event'
5
4
  import { debounce, deepClone, exec, isFunction, isObject, overwriteDeep } from '../utils'
6
5
 
7
- export const IGNORE_STATE_PARAMS = ['update', 'parse', 'clean', 'parent', '__element', '__depends', '__ref']
6
+ export const IGNORE_STATE_PARAMS = ['update', 'parse', 'clean', 'parent', 'systemUpdate', '__system', '__element', '__depends', '__ref']
8
7
 
9
8
  export const parseState = function () {
10
9
  const state = this
@@ -27,6 +26,13 @@ export const cleanState = function () {
27
26
  return state
28
27
  }
29
28
 
29
+ export const systemUpdate = function (obj, options = {}) {
30
+ const state = this
31
+ const rootState = state.__element.__root.state
32
+ rootState.update({ SYSTEM: obj }, options)
33
+ return state
34
+ }
35
+
30
36
  export const updateState = function (obj, options = {}) {
31
37
  const state = this
32
38
  const element = state.__element
@@ -38,10 +44,12 @@ export const updateState = function (obj, options = {}) {
38
44
 
39
45
  overwriteDeep(state, obj, IGNORE_STATE_PARAMS)
40
46
 
41
- if (!options.preventUpdate) debounce(element, update, 150)({}, {
42
- preventStateUpdate: 'once',
43
- ...options
44
- })
47
+ if (!options.preventUpdate) element.update({}, options)
48
+
49
+ // debounce(element, , 150)({}, {
50
+ // // preventStateUpdate: 'once',
51
+ // ...options
52
+ // })
45
53
 
46
54
  if (state.__depends) {
47
55
  for (const el in state.__depends) {
@@ -53,12 +61,12 @@ export const updateState = function (obj, options = {}) {
53
61
 
54
62
  // run `on.stateUpdated`
55
63
  if (element.on && isFunction(element.on.stateUpdated)) {
56
- on.stateUpdated(element.on.stateUpdated, element, state)
64
+ on.stateUpdated(element.on.stateUpdated, element, state, obj)
57
65
  }
58
66
  }
59
67
 
60
68
  export default function (element, parent) {
61
- let { state } = element
69
+ let { state, __root } = element
62
70
 
63
71
  if (!state) {
64
72
  if (parent && parent.state) return parent.state
@@ -82,7 +90,9 @@ export default function (element, parent) {
82
90
  state.clean = cleanState
83
91
  state.parse = parseState
84
92
  state.update = updateState
93
+ state.systemUpdate = systemUpdate
85
94
  state.parent = element.parent.state
95
+ state.__system = __root && __root.state && __root.state.SYSTEM || state.SYSTEM
86
96
 
87
97
  // run `on.stateCreated`
88
98
  if (element.on && isFunction(element.on.stateCreated)) {
package/src/event/on.js CHANGED
@@ -28,8 +28,8 @@ export const initStateUpdated = (param, element, state) => {
28
28
  param(element, state)
29
29
  }
30
30
 
31
- export const stateUpdated = (param, element, state) => {
32
- param(element, state)
31
+ export const stateUpdated = (param, element, state, changes) => {
32
+ param(element, state, changes)
33
33
  }
34
34
 
35
35
  export const update = (param, element, state) => {