@domql/state 2.5.93 → 2.5.131
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/create.js +14 -6
- package/dist/cjs/create.js +11 -5
- package/dist/cjs/methods.js +3 -3
- package/methods.js +3 -3
- package/package.json +2 -2
package/create.js
CHANGED
|
@@ -32,7 +32,7 @@ export const createState = function (element, parent, options) {
|
|
|
32
32
|
export const applyInitialState = function (element, parent, options) {
|
|
33
33
|
const objectizeState = checkForTypes(element)
|
|
34
34
|
if (objectizeState === false) return parent.state || {}
|
|
35
|
-
else element.state =
|
|
35
|
+
else element.state = objectizeState
|
|
36
36
|
|
|
37
37
|
const whatInitReturns = triggerEventOn('stateInit', element, options)
|
|
38
38
|
if (whatInitReturns === false) return element.state
|
|
@@ -54,14 +54,22 @@ export const applyInitialState = function (element, parent, options) {
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
const applyDependentState = (element, state) => {
|
|
57
|
-
const { __ref
|
|
58
|
-
|
|
59
|
-
|
|
57
|
+
const { __ref, ref, __element } = state //
|
|
58
|
+
const origState = exec(__ref || ref || __element?.state, element)
|
|
59
|
+
if (!origState) return
|
|
60
|
+
const dependentState = deepCloneWithExtend(origState, IGNORE_STATE_PARAMS)
|
|
60
61
|
const newDepends = { [element.key]: dependentState }
|
|
61
|
-
|
|
62
|
-
|
|
62
|
+
|
|
63
|
+
const __depends = isObject(origState.__depends)
|
|
64
|
+
? { ...origState.__depends, ...newDepends }
|
|
63
65
|
: newDepends
|
|
64
66
|
|
|
67
|
+
if (Array.isArray(origState)) {
|
|
68
|
+
addProtoToArray(origState, { ...Object.getPrototypeOf(origState), __depends })
|
|
69
|
+
} else {
|
|
70
|
+
Object.setPrototypeOf(origState, { ...Object.getPrototypeOf(origState), __depends })
|
|
71
|
+
}
|
|
72
|
+
|
|
65
73
|
return dependentState
|
|
66
74
|
}
|
|
67
75
|
|
package/dist/cjs/create.js
CHANGED
|
@@ -37,7 +37,7 @@ const applyInitialState = function(element, parent, options) {
|
|
|
37
37
|
if (objectizeState === false)
|
|
38
38
|
return parent.state || {};
|
|
39
39
|
else
|
|
40
|
-
element.state =
|
|
40
|
+
element.state = objectizeState;
|
|
41
41
|
const whatInitReturns = (0, import_event.triggerEventOn)("stateInit", element, options);
|
|
42
42
|
if (whatInitReturns === false)
|
|
43
43
|
return element.state;
|
|
@@ -53,12 +53,18 @@ const applyInitialState = function(element, parent, options) {
|
|
|
53
53
|
return element.state;
|
|
54
54
|
};
|
|
55
55
|
const applyDependentState = (element, state) => {
|
|
56
|
-
const { __ref
|
|
57
|
-
|
|
56
|
+
const { __ref, ref, __element } = state;
|
|
57
|
+
const origState = (0, import_utils.exec)(__ref || ref || (__element == null ? void 0 : __element.state), element);
|
|
58
|
+
if (!origState)
|
|
58
59
|
return;
|
|
59
|
-
const dependentState = (0, import_utils.deepCloneWithExtend)(
|
|
60
|
+
const dependentState = (0, import_utils.deepCloneWithExtend)(origState, import_ignore.IGNORE_STATE_PARAMS);
|
|
60
61
|
const newDepends = { [element.key]: dependentState };
|
|
61
|
-
|
|
62
|
+
const __depends = (0, import_utils.isObject)(origState.__depends) ? { ...origState.__depends, ...newDepends } : newDepends;
|
|
63
|
+
if (Array.isArray(origState)) {
|
|
64
|
+
addProtoToArray(origState, { ...Object.getPrototypeOf(origState), __depends });
|
|
65
|
+
} else {
|
|
66
|
+
Object.setPrototypeOf(origState, { ...Object.getPrototypeOf(origState), __depends });
|
|
67
|
+
}
|
|
62
68
|
return dependentState;
|
|
63
69
|
};
|
|
64
70
|
const checkForTypes = (element) => {
|
package/dist/cjs/methods.js
CHANGED
|
@@ -55,7 +55,7 @@ const parse = function() {
|
|
|
55
55
|
const clean = function(options = {}) {
|
|
56
56
|
const state = this;
|
|
57
57
|
for (const param in state) {
|
|
58
|
-
if (!import_ignore.IGNORE_STATE_PARAMS.includes(param)) {
|
|
58
|
+
if (!import_ignore.IGNORE_STATE_PARAMS.includes(param) && Object.hasOwnProperty.call(state, param)) {
|
|
59
59
|
delete state[param];
|
|
60
60
|
}
|
|
61
61
|
}
|
|
@@ -165,7 +165,7 @@ const applyFunction = function(func, options = {}) {
|
|
|
165
165
|
};
|
|
166
166
|
const quietUpdate = function(obj, options = {}) {
|
|
167
167
|
const state = this;
|
|
168
|
-
return state.update(obj, { preventUpdate: true, options });
|
|
168
|
+
return state.update(obj, { preventUpdate: true, ...options });
|
|
169
169
|
};
|
|
170
170
|
const replace = function(obj, options = {}) {
|
|
171
171
|
const state = this;
|
|
@@ -176,5 +176,5 @@ const replace = function(obj, options = {}) {
|
|
|
176
176
|
};
|
|
177
177
|
const quietReplace = function(obj, options = {}) {
|
|
178
178
|
const state = this;
|
|
179
|
-
return state.replace(obj, { preventUpdate: true, options });
|
|
179
|
+
return state.replace(obj, { preventUpdate: true, ...options });
|
|
180
180
|
};
|
package/methods.js
CHANGED
|
@@ -22,7 +22,7 @@ export const parse = function () {
|
|
|
22
22
|
export const clean = function (options = {}) {
|
|
23
23
|
const state = this
|
|
24
24
|
for (const param in state) {
|
|
25
|
-
if (!IGNORE_STATE_PARAMS.includes(param)) {
|
|
25
|
+
if (!IGNORE_STATE_PARAMS.includes(param) && Object.hasOwnProperty.call(state, param)) {
|
|
26
26
|
delete state[param]
|
|
27
27
|
}
|
|
28
28
|
}
|
|
@@ -147,7 +147,7 @@ export const applyFunction = function (func, options = {}) {
|
|
|
147
147
|
|
|
148
148
|
export const quietUpdate = function (obj, options = {}) {
|
|
149
149
|
const state = this
|
|
150
|
-
return state.update(obj, { preventUpdate: true, options })
|
|
150
|
+
return state.update(obj, { preventUpdate: true, ...options })
|
|
151
151
|
}
|
|
152
152
|
|
|
153
153
|
export const replace = function (obj, options = {}) {
|
|
@@ -162,5 +162,5 @@ export const replace = function (obj, options = {}) {
|
|
|
162
162
|
|
|
163
163
|
export const quietReplace = function (obj, options = {}) {
|
|
164
164
|
const state = this
|
|
165
|
-
return state.replace(obj, { preventUpdate: true, options })
|
|
165
|
+
return state.replace(obj, { preventUpdate: true, ...options })
|
|
166
166
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@domql/state",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.131",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -31,5 +31,5 @@
|
|
|
31
31
|
"@domql/report": "latest",
|
|
32
32
|
"@domql/utils": "latest"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "ede2477daecd2192a473223cfea69bf7363c6e02"
|
|
35
35
|
}
|