@domql/state 2.3.126 → 2.3.128

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/createState.js CHANGED
@@ -3,7 +3,7 @@
3
3
  import { triggerEventOn } from '@domql/event'
4
4
  import { deepClone, exec, is, isFunction, isObject } from '@domql/utils'
5
5
  import { IGNORE_STATE_PARAMS } from './ignore'
6
- import { add, apply, clean, destroy, parse, remove, rootUpdate, set, toggle } from './methods'
6
+ import { add, apply, clean, destroy, parentUpdate, parse, remove, rootUpdate, set, toggle } from './methods'
7
7
  import { updateState } from './updateState'
8
8
  import { checkIfInherits, createInheritedState } from './inherit'
9
9
 
@@ -78,6 +78,7 @@ const applyMethods = (element) => {
78
78
  state.destroy = destroy
79
79
  state.update = updateState
80
80
  state.rootUpdate = rootUpdate
81
+ state.parentUpdate = parentUpdate
81
82
  state.create = createState
82
83
  state.add = add
83
84
  state.toggle = toggle
@@ -87,6 +87,7 @@ const applyMethods = (element) => {
87
87
  state.destroy = import_methods.destroy;
88
88
  state.update = import_updateState.updateState;
89
89
  state.rootUpdate = import_methods.rootUpdate;
90
+ state.parentUpdate = import_methods.parentUpdate;
90
91
  state.create = createState;
91
92
  state.add = import_methods.add;
92
93
  state.toggle = import_methods.toggle;
@@ -33,6 +33,7 @@ const IGNORE_STATE_PARAMS = [
33
33
  "apply",
34
34
  "set",
35
35
  "rootUpdate",
36
+ "parentUpdate",
36
37
  "parent",
37
38
  "__element",
38
39
  "__depends",
@@ -22,6 +22,7 @@ __export(methods_exports, {
22
22
  apply: () => apply,
23
23
  clean: () => clean,
24
24
  destroy: () => destroy,
25
+ parentUpdate: () => parentUpdate,
25
26
  parse: () => parse,
26
27
  remove: () => remove,
27
28
  rootUpdate: () => rootUpdate,
@@ -81,11 +82,16 @@ const destroy = function(options = {}) {
81
82
  element.state.update({}, { isHoisted: true, ...options });
82
83
  return element.state;
83
84
  };
85
+ const parentUpdate = function(obj, options = {}) {
86
+ const state = this;
87
+ if (!state || !state.parent)
88
+ return;
89
+ return state.parent.update(obj, { isHoisted: true, ...options });
90
+ };
84
91
  const rootUpdate = function(obj, options = {}) {
85
92
  const state = this;
86
93
  if (!state)
87
94
  return;
88
- console.log(options);
89
95
  const rootState = state.__element.__ref.__root.state;
90
96
  return rootState.update(obj, options);
91
97
  };
@@ -124,6 +124,7 @@ const applyElementUpdate = (state, obj, options) => {
124
124
  } else if (options.preventUpdate === "recursive") {
125
125
  element.update({}, {
126
126
  ...options,
127
+ isHoisted: false,
127
128
  updateByState: true,
128
129
  preventUpdate: true
129
130
  });
package/ignore.js CHANGED
@@ -2,5 +2,5 @@
2
2
 
3
3
  export const IGNORE_STATE_PARAMS = [
4
4
  'update', 'parse', 'clean', 'create', 'destroy', 'add', 'toggle', 'remove', 'apply', 'set',
5
- 'rootUpdate', 'parent', '__element', '__depends', '__ref', '__children', '__root'
5
+ 'rootUpdate', 'parentUpdate', 'parent', '__element', '__depends', '__ref', '__children', '__root'
6
6
  ]
package/methods.js CHANGED
@@ -62,10 +62,15 @@ export const destroy = function (options = {}) {
62
62
  return element.state
63
63
  }
64
64
 
65
+ export const parentUpdate = function (obj, options = {}) {
66
+ const state = this
67
+ if (!state || !state.parent) return
68
+ return state.parent.update(obj, { isHoisted: true, ...options })
69
+ }
70
+
65
71
  export const rootUpdate = function (obj, options = {}) {
66
72
  const state = this
67
73
  if (!state) return
68
- console.log(options)
69
74
  const rootState = (state.__element.__ref.__root).state
70
75
  return rootState.update(obj, options)
71
76
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@domql/state",
3
- "version": "2.3.126",
3
+ "version": "2.3.128",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "module": "dist/esm/index.js",
@@ -26,5 +26,5 @@
26
26
  "@domql/report": "latest",
27
27
  "@domql/utils": "latest"
28
28
  },
29
- "gitHead": "6329de71d2e831d0efd9d59e765567aa8c563481"
29
+ "gitHead": "bcca09a4dd5507f516af99a88205f227a5deb8ba"
30
30
  }
package/updateState.js CHANGED
@@ -114,6 +114,7 @@ const applyElementUpdate = (state, obj, options) => {
114
114
  } else if (options.preventUpdate === 'recursive') {
115
115
  element.update({}, {
116
116
  ...options,
117
+ isHoisted: false,
117
118
  updateByState: true,
118
119
  preventUpdate: true
119
120
  })