@domql/element 2.31.30 → 2.31.31
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 +2 -2
- package/dist/cjs/create.js +2 -0
- package/dist/cjs/methods/index.js +1 -1
- package/dist/cjs/update.js +37 -36
- package/dist/esm/create.js +2 -0
- package/dist/esm/methods/index.js +1 -1
- package/dist/esm/update.js +37 -36
- package/methods/index.js +1 -1
- package/package.json +6 -6
- package/update.js +47 -47
package/create.js
CHANGED
|
@@ -91,12 +91,11 @@ export const create = async (
|
|
|
91
91
|
return await onlyResolveExtends(element, parent, key, options)
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
+
await triggerEventOn('eventStart', element, options)
|
|
94
95
|
await triggerEventOn('start', element, options)
|
|
95
96
|
|
|
96
97
|
switchDefaultOptions(element, parent, options)
|
|
97
|
-
|
|
98
98
|
addCaching(element, parent, options)
|
|
99
|
-
|
|
100
99
|
addMethods(element, parent, options)
|
|
101
100
|
|
|
102
101
|
createScope(element, parent, options)
|
|
@@ -137,6 +136,7 @@ export const create = async (
|
|
|
137
136
|
addElementIntoParentChildren(element, parent)
|
|
138
137
|
|
|
139
138
|
await triggerEventOn('complete', element, options)
|
|
139
|
+
await triggerEventOn('eventComplete', element, options)
|
|
140
140
|
|
|
141
141
|
return element
|
|
142
142
|
}
|
package/dist/cjs/create.js
CHANGED
|
@@ -67,6 +67,7 @@ const create = async (element, parent2, key, options = import_options.OPTIONS.cr
|
|
|
67
67
|
if (options.onlyResolveExtends) {
|
|
68
68
|
return await onlyResolveExtends(element, parent2, key, options);
|
|
69
69
|
}
|
|
70
|
+
await (0, import_event.triggerEventOn)("eventStart", element, options);
|
|
70
71
|
await (0, import_event.triggerEventOn)("start", element, options);
|
|
71
72
|
switchDefaultOptions(element, parent2, options);
|
|
72
73
|
addCaching(element, parent2, options);
|
|
@@ -91,6 +92,7 @@ const create = async (element, parent2, key, options = import_options.OPTIONS.cr
|
|
|
91
92
|
await renderElement(element, parent2, options, attachOptions);
|
|
92
93
|
addElementIntoParentChildren(element, parent2);
|
|
93
94
|
await (0, import_event.triggerEventOn)("complete", element, options);
|
|
95
|
+
await (0, import_event.triggerEventOn)("eventComplete", element, options);
|
|
94
96
|
return element;
|
|
95
97
|
};
|
|
96
98
|
const createBasedOnType = (element, parent2, key, options) => {
|
package/dist/cjs/update.js
CHANGED
|
@@ -48,39 +48,22 @@ const update = async function(params = {}, opts) {
|
|
|
48
48
|
const calleeElementCache = opts == null ? void 0 : opts.calleeElement;
|
|
49
49
|
const options = (0, import_utils.deepClone)(
|
|
50
50
|
(0, import_utils.isObject)(opts) ? (0, import_utils2.deepMerge)(opts, UPDATE_DEFAULT_OPTIONS) : UPDATE_DEFAULT_OPTIONS,
|
|
51
|
-
{ exclude: ["calleeElement"] }
|
|
51
|
+
{ exclude: ["calleeElement", "updatingCalleeElement"] }
|
|
52
52
|
);
|
|
53
53
|
const element = this;
|
|
54
|
-
options.calleeElement = calleeElementCache
|
|
54
|
+
options.calleeElement = calleeElementCache;
|
|
55
55
|
const { parent, node, key } = element;
|
|
56
56
|
const { excludes, preventInheritAtCurrentState } = options;
|
|
57
57
|
let ref = element.__ref;
|
|
58
58
|
if (!ref) ref = element.__ref = {};
|
|
59
|
-
if (ref.__stormAbortion && !options.allowStorm) {
|
|
60
|
-
const stormAbortion = setTimeout(() => {
|
|
61
|
-
delete ref.__stormAbortion;
|
|
62
|
-
clearTimeout(stormAbortion);
|
|
63
|
-
}, 1e3);
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
if (this === options.calleeElement && !options.allowStorm) {
|
|
67
|
-
if (ref.__selfCallIteration === void 0) ref.__selfCallIteration = 0;
|
|
68
|
-
else ref.__selfCallIteration++;
|
|
69
|
-
if (ref.__selfCallIteration > 100) {
|
|
70
|
-
ref.__selfCallIteration = 0;
|
|
71
|
-
ref.__stormAbortion = true;
|
|
72
|
-
return this.error("Potential self calling loop in update detected", opts);
|
|
73
|
-
}
|
|
74
|
-
const stormTimeout = setTimeout(() => {
|
|
75
|
-
ref.__selfCallIteration = 0;
|
|
76
|
-
clearTimeout(stormTimeout);
|
|
77
|
-
}, 350);
|
|
78
|
-
}
|
|
79
59
|
const [snapshotOnCallee, calleeElement, snapshotHasUpdated] = captureSnapshot(
|
|
80
60
|
element,
|
|
81
61
|
options
|
|
82
62
|
);
|
|
83
63
|
if (snapshotHasUpdated) return;
|
|
64
|
+
if (checkIfStorm(element, options)) return;
|
|
65
|
+
if (!options.preventListeners)
|
|
66
|
+
await (0, import_event.triggerEventOn)("eventStart", element, options);
|
|
84
67
|
if (!options.preventListeners)
|
|
85
68
|
await (0, import_event.triggerEventOnUpdate)("startUpdate", params, element, options);
|
|
86
69
|
if (preventInheritAtCurrentState && preventInheritAtCurrentState.__element === element)
|
|
@@ -168,7 +151,36 @@ const update = async function(params = {}, opts) {
|
|
|
168
151
|
}) : await childUpdateCall();
|
|
169
152
|
}
|
|
170
153
|
}
|
|
171
|
-
if (!
|
|
154
|
+
if (!options.preventListeners) {
|
|
155
|
+
if (!preventUpdateListener) await (0, import_event.triggerEventOn)("update", element, options);
|
|
156
|
+
await (0, import_event.triggerEventOn)("eventComplete", element, options);
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
const checkIfStorm = (element, options) => {
|
|
160
|
+
let ref = element.__ref;
|
|
161
|
+
if (!options.updatingCalleeElement) options.updatingCalleeElement = element;
|
|
162
|
+
if (ref.__stormAbortion && !options.allowStorm) {
|
|
163
|
+
const stormAbortion = setTimeout(() => {
|
|
164
|
+
delete ref.__stormAbortion;
|
|
165
|
+
clearTimeout(stormAbortion);
|
|
166
|
+
}, 1e3);
|
|
167
|
+
element.error("Potential storm update detected", options);
|
|
168
|
+
return true;
|
|
169
|
+
}
|
|
170
|
+
if (element === options.updatingCalleeElement && !options.allowStorm) {
|
|
171
|
+
if (ref.__selfCallIteration === void 0) ref.__selfCallIteration = 0;
|
|
172
|
+
else ref.__selfCallIteration++;
|
|
173
|
+
if (ref.__selfCallIteration > 100) {
|
|
174
|
+
ref.__selfCallIteration = 0;
|
|
175
|
+
ref.__stormAbortion = true;
|
|
176
|
+
element.error("Potential self calling loop in update detected", options);
|
|
177
|
+
return true;
|
|
178
|
+
}
|
|
179
|
+
const stormTimeout = setTimeout(() => {
|
|
180
|
+
ref.__selfCallIteration = 0;
|
|
181
|
+
clearTimeout(stormTimeout);
|
|
182
|
+
}, 350);
|
|
183
|
+
}
|
|
172
184
|
};
|
|
173
185
|
const captureSnapshot = (element, options) => {
|
|
174
186
|
const ref = element.__ref;
|
|
@@ -252,24 +264,13 @@ const checkIfOnUpdate = (element, parent, options) => {
|
|
|
252
264
|
const inheritStateUpdates = async (element, options) => {
|
|
253
265
|
const { __ref: ref } = element;
|
|
254
266
|
const stateKey = ref.__state;
|
|
255
|
-
const { parent
|
|
256
|
-
const { preventUpdateTriggerStateUpdate
|
|
267
|
+
const { parent } = element;
|
|
268
|
+
const { preventUpdateTriggerStateUpdate } = options;
|
|
257
269
|
if (preventUpdateTriggerStateUpdate) return;
|
|
258
270
|
if (!stateKey && !ref.__hasRootState) {
|
|
259
271
|
element.state = parent && parent.state || {};
|
|
260
272
|
return;
|
|
261
273
|
}
|
|
262
|
-
const shouldForceFunctionState = (0, import_utils.isFunction)(stateKey) && !isHoisted && execStateFunction;
|
|
263
|
-
if (shouldForceFunctionState) {
|
|
264
|
-
const execState = (0, import_utils.exec)(stateKey, element);
|
|
265
|
-
state.set(execState, {
|
|
266
|
-
...options,
|
|
267
|
-
preventUpdate: true,
|
|
268
|
-
preventStateUpdateListener: false,
|
|
269
|
-
updatedByStateFunction: true
|
|
270
|
-
});
|
|
271
|
-
return;
|
|
272
|
-
}
|
|
273
274
|
const keyInParentState = (0, import_state.findInheritedState)(element, element.parent);
|
|
274
275
|
if (!keyInParentState || options.preventInheritedStateUpdate) return;
|
|
275
276
|
if (!options.preventBeforeStateUpdateListener && !options.preventListeners) {
|
package/dist/esm/create.js
CHANGED
|
@@ -63,6 +63,7 @@ const create = async (element, parent2, key, options = OPTIONS.create || {}, att
|
|
|
63
63
|
if (options.onlyResolveExtends) {
|
|
64
64
|
return await onlyResolveExtends(element, parent2, key, options);
|
|
65
65
|
}
|
|
66
|
+
await triggerEventOn("eventStart", element, options);
|
|
66
67
|
await triggerEventOn("start", element, options);
|
|
67
68
|
switchDefaultOptions(element, parent2, options);
|
|
68
69
|
addCaching(element, parent2, options);
|
|
@@ -87,6 +88,7 @@ const create = async (element, parent2, key, options = OPTIONS.create || {}, att
|
|
|
87
88
|
await renderElement(element, parent2, options, attachOptions);
|
|
88
89
|
addElementIntoParentChildren(element, parent2);
|
|
89
90
|
await triggerEventOn("complete", element, options);
|
|
91
|
+
await triggerEventOn("eventComplete", element, options);
|
|
90
92
|
return element;
|
|
91
93
|
};
|
|
92
94
|
const createBasedOnType = (element, parent2, key, options) => {
|
package/dist/esm/update.js
CHANGED
|
@@ -42,39 +42,22 @@ const update = async function(params = {}, opts) {
|
|
|
42
42
|
const calleeElementCache = opts == null ? void 0 : opts.calleeElement;
|
|
43
43
|
const options = deepClone(
|
|
44
44
|
isObject(opts) ? deepMerge(opts, UPDATE_DEFAULT_OPTIONS) : UPDATE_DEFAULT_OPTIONS,
|
|
45
|
-
{ exclude: ["calleeElement"] }
|
|
45
|
+
{ exclude: ["calleeElement", "updatingCalleeElement"] }
|
|
46
46
|
);
|
|
47
47
|
const element = this;
|
|
48
|
-
options.calleeElement = calleeElementCache
|
|
48
|
+
options.calleeElement = calleeElementCache;
|
|
49
49
|
const { parent, node, key } = element;
|
|
50
50
|
const { excludes, preventInheritAtCurrentState } = options;
|
|
51
51
|
let ref = element.__ref;
|
|
52
52
|
if (!ref) ref = element.__ref = {};
|
|
53
|
-
if (ref.__stormAbortion && !options.allowStorm) {
|
|
54
|
-
const stormAbortion = setTimeout(() => {
|
|
55
|
-
delete ref.__stormAbortion;
|
|
56
|
-
clearTimeout(stormAbortion);
|
|
57
|
-
}, 1e3);
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
if (this === options.calleeElement && !options.allowStorm) {
|
|
61
|
-
if (ref.__selfCallIteration === void 0) ref.__selfCallIteration = 0;
|
|
62
|
-
else ref.__selfCallIteration++;
|
|
63
|
-
if (ref.__selfCallIteration > 100) {
|
|
64
|
-
ref.__selfCallIteration = 0;
|
|
65
|
-
ref.__stormAbortion = true;
|
|
66
|
-
return this.error("Potential self calling loop in update detected", opts);
|
|
67
|
-
}
|
|
68
|
-
const stormTimeout = setTimeout(() => {
|
|
69
|
-
ref.__selfCallIteration = 0;
|
|
70
|
-
clearTimeout(stormTimeout);
|
|
71
|
-
}, 350);
|
|
72
|
-
}
|
|
73
53
|
const [snapshotOnCallee, calleeElement, snapshotHasUpdated] = captureSnapshot(
|
|
74
54
|
element,
|
|
75
55
|
options
|
|
76
56
|
);
|
|
77
57
|
if (snapshotHasUpdated) return;
|
|
58
|
+
if (checkIfStorm(element, options)) return;
|
|
59
|
+
if (!options.preventListeners)
|
|
60
|
+
await triggerEventOn("eventStart", element, options);
|
|
78
61
|
if (!options.preventListeners)
|
|
79
62
|
await triggerEventOnUpdate("startUpdate", params, element, options);
|
|
80
63
|
if (preventInheritAtCurrentState && preventInheritAtCurrentState.__element === element)
|
|
@@ -162,7 +145,36 @@ const update = async function(params = {}, opts) {
|
|
|
162
145
|
}) : await childUpdateCall();
|
|
163
146
|
}
|
|
164
147
|
}
|
|
165
|
-
if (!
|
|
148
|
+
if (!options.preventListeners) {
|
|
149
|
+
if (!preventUpdateListener) await triggerEventOn("update", element, options);
|
|
150
|
+
await triggerEventOn("eventComplete", element, options);
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
const checkIfStorm = (element, options) => {
|
|
154
|
+
let ref = element.__ref;
|
|
155
|
+
if (!options.updatingCalleeElement) options.updatingCalleeElement = element;
|
|
156
|
+
if (ref.__stormAbortion && !options.allowStorm) {
|
|
157
|
+
const stormAbortion = setTimeout(() => {
|
|
158
|
+
delete ref.__stormAbortion;
|
|
159
|
+
clearTimeout(stormAbortion);
|
|
160
|
+
}, 1e3);
|
|
161
|
+
element.error("Potential storm update detected", options);
|
|
162
|
+
return true;
|
|
163
|
+
}
|
|
164
|
+
if (element === options.updatingCalleeElement && !options.allowStorm) {
|
|
165
|
+
if (ref.__selfCallIteration === void 0) ref.__selfCallIteration = 0;
|
|
166
|
+
else ref.__selfCallIteration++;
|
|
167
|
+
if (ref.__selfCallIteration > 100) {
|
|
168
|
+
ref.__selfCallIteration = 0;
|
|
169
|
+
ref.__stormAbortion = true;
|
|
170
|
+
element.error("Potential self calling loop in update detected", options);
|
|
171
|
+
return true;
|
|
172
|
+
}
|
|
173
|
+
const stormTimeout = setTimeout(() => {
|
|
174
|
+
ref.__selfCallIteration = 0;
|
|
175
|
+
clearTimeout(stormTimeout);
|
|
176
|
+
}, 350);
|
|
177
|
+
}
|
|
166
178
|
};
|
|
167
179
|
const captureSnapshot = (element, options) => {
|
|
168
180
|
const ref = element.__ref;
|
|
@@ -246,24 +258,13 @@ const checkIfOnUpdate = (element, parent, options) => {
|
|
|
246
258
|
const inheritStateUpdates = async (element, options) => {
|
|
247
259
|
const { __ref: ref } = element;
|
|
248
260
|
const stateKey = ref.__state;
|
|
249
|
-
const { parent
|
|
250
|
-
const { preventUpdateTriggerStateUpdate
|
|
261
|
+
const { parent } = element;
|
|
262
|
+
const { preventUpdateTriggerStateUpdate } = options;
|
|
251
263
|
if (preventUpdateTriggerStateUpdate) return;
|
|
252
264
|
if (!stateKey && !ref.__hasRootState) {
|
|
253
265
|
element.state = parent && parent.state || {};
|
|
254
266
|
return;
|
|
255
267
|
}
|
|
256
|
-
const shouldForceFunctionState = isFunction(stateKey) && !isHoisted && execStateFunction;
|
|
257
|
-
if (shouldForceFunctionState) {
|
|
258
|
-
const execState = exec(stateKey, element);
|
|
259
|
-
state.set(execState, {
|
|
260
|
-
...options,
|
|
261
|
-
preventUpdate: true,
|
|
262
|
-
preventStateUpdateListener: false,
|
|
263
|
-
updatedByStateFunction: true
|
|
264
|
-
});
|
|
265
|
-
return;
|
|
266
|
-
}
|
|
267
268
|
const keyInParentState = findInheritedState(element, element.parent);
|
|
268
269
|
if (!keyInParentState || options.preventInheritedStateUpdate) return;
|
|
269
270
|
if (!options.preventBeforeStateUpdateListener && !options.preventListeners) {
|
package/methods/index.js
CHANGED
|
@@ -377,7 +377,7 @@ export function call(fnKey, ...args) {
|
|
|
377
377
|
// Return synchronous results directly
|
|
378
378
|
return result
|
|
379
379
|
} catch (error) {
|
|
380
|
-
console.error(`Error calling '${fnKey}'`)
|
|
380
|
+
console.error(`Error calling function: '${fnKey}'`)
|
|
381
381
|
throw new Error(error)
|
|
382
382
|
}
|
|
383
383
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@domql/element",
|
|
3
|
-
"version": "2.31.
|
|
3
|
+
"version": "2.31.31",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "index.js",
|
|
@@ -27,12 +27,12 @@
|
|
|
27
27
|
"prepublish": "npx rimraf -I dist && npm run build && npm run copy:package:cjs"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@domql/event": "^2.31.
|
|
31
|
-
"@domql/render": "^2.31.
|
|
32
|
-
"@domql/state": "^2.31.
|
|
33
|
-
"@domql/utils": "^2.31.
|
|
30
|
+
"@domql/event": "^2.31.31",
|
|
31
|
+
"@domql/render": "^2.31.31",
|
|
32
|
+
"@domql/state": "^2.31.31",
|
|
33
|
+
"@domql/utils": "^2.31.31"
|
|
34
34
|
},
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "a87c7ae3e84fbab1a9ee130d6d03f384e94260ab",
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@babel/core": "^7.27.1"
|
|
38
38
|
}
|
package/update.js
CHANGED
|
@@ -56,48 +56,27 @@ export const update = async function (params = {}, opts) {
|
|
|
56
56
|
isObject(opts)
|
|
57
57
|
? deepMerge(opts, UPDATE_DEFAULT_OPTIONS)
|
|
58
58
|
: UPDATE_DEFAULT_OPTIONS,
|
|
59
|
-
{ exclude: ['calleeElement'] }
|
|
59
|
+
{ exclude: ['calleeElement', 'updatingCalleeElement'] }
|
|
60
60
|
)
|
|
61
61
|
const element = this
|
|
62
|
-
options.calleeElement = calleeElementCache
|
|
62
|
+
options.calleeElement = calleeElementCache
|
|
63
63
|
const { parent, node, key } = element
|
|
64
64
|
const { excludes, preventInheritAtCurrentState } = options
|
|
65
65
|
|
|
66
66
|
let ref = element.__ref
|
|
67
67
|
if (!ref) ref = element.__ref = {}
|
|
68
68
|
|
|
69
|
-
if (ref.__stormAbortion && !options.allowStorm) {
|
|
70
|
-
// make storm abourtion time based
|
|
71
|
-
const stormAbortion = setTimeout(() => {
|
|
72
|
-
delete ref.__stormAbortion
|
|
73
|
-
clearTimeout(stormAbortion)
|
|
74
|
-
}, 1000)
|
|
75
|
-
return
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// self calling is detected
|
|
79
|
-
if (this === options.calleeElement && !options.allowStorm) {
|
|
80
|
-
if (ref.__selfCallIteration === undefined) ref.__selfCallIteration = 0
|
|
81
|
-
else ref.__selfCallIteration++
|
|
82
|
-
// prevent storm
|
|
83
|
-
if (ref.__selfCallIteration > 100) {
|
|
84
|
-
ref.__selfCallIteration = 0
|
|
85
|
-
ref.__stormAbortion = true
|
|
86
|
-
return this.error('Potential self calling loop in update detected', opts)
|
|
87
|
-
}
|
|
88
|
-
// make storm detection time based
|
|
89
|
-
const stormTimeout = setTimeout(() => {
|
|
90
|
-
ref.__selfCallIteration = 0
|
|
91
|
-
clearTimeout(stormTimeout)
|
|
92
|
-
}, 350)
|
|
93
|
-
}
|
|
94
|
-
|
|
95
69
|
const [snapshotOnCallee, calleeElement, snapshotHasUpdated] = captureSnapshot(
|
|
96
70
|
element,
|
|
97
71
|
options
|
|
98
72
|
)
|
|
99
73
|
if (snapshotHasUpdated) return
|
|
100
74
|
|
|
75
|
+
if (checkIfStorm(element, options)) return
|
|
76
|
+
|
|
77
|
+
if (!options.preventListeners)
|
|
78
|
+
await triggerEventOn('eventStart', element, options)
|
|
79
|
+
|
|
101
80
|
if (!options.preventListeners)
|
|
102
81
|
await triggerEventOnUpdate('startUpdate', params, element, options)
|
|
103
82
|
|
|
@@ -241,7 +220,44 @@ export const update = async function (params = {}, opts) {
|
|
|
241
220
|
}
|
|
242
221
|
}
|
|
243
222
|
|
|
244
|
-
if (!
|
|
223
|
+
if (!options.preventListeners) {
|
|
224
|
+
if (!preventUpdateListener) await triggerEventOn('update', element, options)
|
|
225
|
+
await triggerEventOn('eventComplete', element, options)
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
const checkIfStorm = (element, options) => {
|
|
230
|
+
let ref = element.__ref
|
|
231
|
+
|
|
232
|
+
if (!options.updatingCalleeElement) options.updatingCalleeElement = element
|
|
233
|
+
|
|
234
|
+
if (ref.__stormAbortion && !options.allowStorm) {
|
|
235
|
+
// make storm abourtion time based
|
|
236
|
+
const stormAbortion = setTimeout(() => {
|
|
237
|
+
delete ref.__stormAbortion
|
|
238
|
+
clearTimeout(stormAbortion)
|
|
239
|
+
}, 1000)
|
|
240
|
+
element.error('Potential storm update detected', options)
|
|
241
|
+
return true
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
// self calling is detected
|
|
245
|
+
if (element === options.updatingCalleeElement && !options.allowStorm) {
|
|
246
|
+
if (ref.__selfCallIteration === undefined) ref.__selfCallIteration = 0
|
|
247
|
+
else ref.__selfCallIteration++
|
|
248
|
+
// prevent storm
|
|
249
|
+
if (ref.__selfCallIteration > 100) {
|
|
250
|
+
ref.__selfCallIteration = 0
|
|
251
|
+
ref.__stormAbortion = true
|
|
252
|
+
element.error('Potential self calling loop in update detected', options)
|
|
253
|
+
return true
|
|
254
|
+
}
|
|
255
|
+
// make storm detection time based
|
|
256
|
+
const stormTimeout = setTimeout(() => {
|
|
257
|
+
ref.__selfCallIteration = 0
|
|
258
|
+
clearTimeout(stormTimeout)
|
|
259
|
+
}, 350)
|
|
260
|
+
}
|
|
245
261
|
}
|
|
246
262
|
|
|
247
263
|
const captureSnapshot = (element, options) => {
|
|
@@ -355,7 +371,6 @@ const checkIfOnUpdate = (element, parent, options) => {
|
|
|
355
371
|
* @param {Object} options - Configuration options for state update inheritance.
|
|
356
372
|
* @param {boolean} [options.preventUpdateTriggerStateUpdate] - If true, prevent triggering state updates.
|
|
357
373
|
* @param {boolean} [options.isHoisted] - Whether the state is hoisted.
|
|
358
|
-
* @param {boolean} [options.execStateFunction] - Execute the state functions.
|
|
359
374
|
* @param {boolean} [options.stateFunctionOverwrite] - If true, overwrite (not merge) current state with what function returns.
|
|
360
375
|
* @param {boolean} [options.preventInheritedStateUpdate] - If true, prevent inheriting state updates.
|
|
361
376
|
* @param {boolean} [options.preventBeforeStateUpdateListener] - If true, prevent the 'beforeStateUpdate' event listener.
|
|
@@ -365,9 +380,8 @@ const checkIfOnUpdate = (element, parent, options) => {
|
|
|
365
380
|
const inheritStateUpdates = async (element, options) => {
|
|
366
381
|
const { __ref: ref } = element
|
|
367
382
|
const stateKey = ref.__state
|
|
368
|
-
const { parent
|
|
369
|
-
const { preventUpdateTriggerStateUpdate
|
|
370
|
-
options
|
|
383
|
+
const { parent } = element
|
|
384
|
+
const { preventUpdateTriggerStateUpdate } = options
|
|
371
385
|
|
|
372
386
|
if (preventUpdateTriggerStateUpdate) return
|
|
373
387
|
|
|
@@ -377,20 +391,6 @@ const inheritStateUpdates = async (element, options) => {
|
|
|
377
391
|
return
|
|
378
392
|
}
|
|
379
393
|
|
|
380
|
-
// If state is function, decide execution and apply setting a current state
|
|
381
|
-
const shouldForceFunctionState =
|
|
382
|
-
isFunction(stateKey) && !isHoisted && execStateFunction
|
|
383
|
-
if (shouldForceFunctionState) {
|
|
384
|
-
const execState = exec(stateKey, element)
|
|
385
|
-
state.set(execState, {
|
|
386
|
-
...options,
|
|
387
|
-
preventUpdate: true,
|
|
388
|
-
preventStateUpdateListener: false,
|
|
389
|
-
updatedByStateFunction: true
|
|
390
|
-
})
|
|
391
|
-
return
|
|
392
|
-
}
|
|
393
|
-
|
|
394
394
|
// If state is string, find its value in the state tree
|
|
395
395
|
const keyInParentState = findInheritedState(element, element.parent)
|
|
396
396
|
if (!keyInParentState || options.preventInheritedStateUpdate) return
|