@domql/state 2.5.47 → 2.5.53
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/dist/cjs/updateState.js +8 -6
- package/package.json +2 -2
- package/updateState.js +7 -6
package/dist/cjs/updateState.js
CHANGED
|
@@ -45,7 +45,7 @@ const updateState = function(obj, options = STATE_UPDATE_OPTIONS) {
|
|
|
45
45
|
} else if (options.preventInheritAtCurrentState)
|
|
46
46
|
return;
|
|
47
47
|
if (!options.preventInitStateUpdateListener) {
|
|
48
|
-
const initStateUpdateReturns = (0, import_event.triggerEventOnUpdate)("
|
|
48
|
+
const initStateUpdateReturns = (0, import_event.triggerEventOnUpdate)("initStateUpdate", obj, element, options);
|
|
49
49
|
if (initStateUpdateReturns === false)
|
|
50
50
|
return element;
|
|
51
51
|
}
|
|
@@ -56,7 +56,7 @@ const updateState = function(obj, options = STATE_UPDATE_OPTIONS) {
|
|
|
56
56
|
updateDependentState(state, obj, options);
|
|
57
57
|
applyElementUpdate(state, obj, options);
|
|
58
58
|
if (!options.preventStateUpdateListener) {
|
|
59
|
-
(0, import_event.triggerEventOnUpdate)("
|
|
59
|
+
(0, import_event.triggerEventOnUpdate)("stateUpdate", obj, element, options);
|
|
60
60
|
}
|
|
61
61
|
return state;
|
|
62
62
|
};
|
|
@@ -64,13 +64,15 @@ const applyOverwrite = (state, obj, options) => {
|
|
|
64
64
|
const { overwrite } = options;
|
|
65
65
|
if (!overwrite)
|
|
66
66
|
return;
|
|
67
|
-
const shallow = overwrite === "shallow";
|
|
67
|
+
const shallow = overwrite === "shallow" || overwrite === "shallow-once";
|
|
68
68
|
const merge2 = overwrite === "merge";
|
|
69
69
|
if (merge2) {
|
|
70
70
|
(0, import_utils.deepMerge)(state, obj, import_ignore.IGNORE_STATE_PARAMS);
|
|
71
71
|
return;
|
|
72
72
|
}
|
|
73
73
|
const overwriteFunc = shallow ? import_utils.overwriteShallow : import_utils.overwriteDeep;
|
|
74
|
+
if (options.overwrite === "shallow-once")
|
|
75
|
+
options.overwrite = true;
|
|
74
76
|
overwriteFunc(state, obj, import_ignore.IGNORE_STATE_PARAMS);
|
|
75
77
|
};
|
|
76
78
|
const hoistStateUpdate = (state, obj, options) => {
|
|
@@ -96,13 +98,13 @@ const hoistStateUpdate = (state, obj, options) => {
|
|
|
96
98
|
targetParent.update(changesValue, {
|
|
97
99
|
execStateFunction: false,
|
|
98
100
|
isHoisted: true,
|
|
99
|
-
...options,
|
|
100
101
|
preventUpdate: options.preventHoistElementUpdate,
|
|
101
|
-
overwrite: !options.replace
|
|
102
|
+
overwrite: !options.replace,
|
|
103
|
+
...options
|
|
102
104
|
});
|
|
103
105
|
const hasNotUpdated = options.preventUpdate !== true || !options.preventHoistElementUpdate;
|
|
104
106
|
if (!options.preventStateUpdateListener && hasNotUpdated) {
|
|
105
|
-
(0, import_event.triggerEventOnUpdate)("
|
|
107
|
+
(0, import_event.triggerEventOnUpdate)("stateUpdate", obj, element, options);
|
|
106
108
|
}
|
|
107
109
|
return true;
|
|
108
110
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@domql/state",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.53",
|
|
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": "aafcffa2ebe3d9c2fb96bd3adcb05325b62e68ff"
|
|
35
35
|
}
|
package/updateState.js
CHANGED
|
@@ -26,7 +26,7 @@ export const updateState = function (obj, options = STATE_UPDATE_OPTIONS) {
|
|
|
26
26
|
} else if (options.preventInheritAtCurrentState) return
|
|
27
27
|
|
|
28
28
|
if (!options.preventInitStateUpdateListener) {
|
|
29
|
-
const initStateUpdateReturns = triggerEventOnUpdate('
|
|
29
|
+
const initStateUpdateReturns = triggerEventOnUpdate('initStateUpdate', obj, element, options)
|
|
30
30
|
if (initStateUpdateReturns === false) return element
|
|
31
31
|
}
|
|
32
32
|
|
|
@@ -39,7 +39,7 @@ export const updateState = function (obj, options = STATE_UPDATE_OPTIONS) {
|
|
|
39
39
|
applyElementUpdate(state, obj, options)
|
|
40
40
|
|
|
41
41
|
if (!options.preventStateUpdateListener) {
|
|
42
|
-
triggerEventOnUpdate('
|
|
42
|
+
triggerEventOnUpdate('stateUpdate', obj, element, options)
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
return state
|
|
@@ -49,7 +49,7 @@ const applyOverwrite = (state, obj, options) => {
|
|
|
49
49
|
const { overwrite } = options
|
|
50
50
|
if (!overwrite) return
|
|
51
51
|
|
|
52
|
-
const shallow = overwrite === 'shallow'
|
|
52
|
+
const shallow = overwrite === 'shallow' || overwrite === 'shallow-once'
|
|
53
53
|
const merge = overwrite === 'merge'
|
|
54
54
|
|
|
55
55
|
if (merge) {
|
|
@@ -58,6 +58,7 @@ const applyOverwrite = (state, obj, options) => {
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
const overwriteFunc = shallow ? overwriteShallow : overwriteDeep
|
|
61
|
+
if (options.overwrite === 'shallow-once') options.overwrite = true
|
|
61
62
|
overwriteFunc(state, obj, IGNORE_STATE_PARAMS)
|
|
62
63
|
}
|
|
63
64
|
|
|
@@ -84,13 +85,13 @@ const hoistStateUpdate = (state, obj, options) => {
|
|
|
84
85
|
targetParent.update(changesValue, {
|
|
85
86
|
execStateFunction: false,
|
|
86
87
|
isHoisted: true,
|
|
87
|
-
...options,
|
|
88
88
|
preventUpdate: options.preventHoistElementUpdate,
|
|
89
|
-
overwrite: !options.replace
|
|
89
|
+
overwrite: !options.replace,
|
|
90
|
+
...options
|
|
90
91
|
})
|
|
91
92
|
const hasNotUpdated = options.preventUpdate !== true || !options.preventHoistElementUpdate
|
|
92
93
|
if (!options.preventStateUpdateListener && hasNotUpdated) {
|
|
93
|
-
triggerEventOnUpdate('
|
|
94
|
+
triggerEventOnUpdate('stateUpdate', obj, element, options)
|
|
94
95
|
}
|
|
95
96
|
return true
|
|
96
97
|
}
|