juxscript 1.1.293 → 1.1.294
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/lib/state/pageState.js +17 -18
- package/package.json +1 -1
|
@@ -254,24 +254,26 @@ class PageState {
|
|
|
254
254
|
this._registry.delete(id);
|
|
255
255
|
}
|
|
256
256
|
_notify(depKey) {
|
|
257
|
-
// For event-style keys, set the flag before notifying
|
|
258
|
-
const dotIdx = depKey.indexOf('.');
|
|
259
|
-
const eventId = dotIdx > -1 ? depKey.substring(0, dotIdx) : null;
|
|
260
|
-
const eventProp = dotIdx > -1 ? depKey.substring(dotIdx + 1) : null;
|
|
261
|
-
if (eventId && eventProp) {
|
|
262
|
-
const entry = this._registry.get(eventId);
|
|
263
|
-
if (entry && eventProp in entry.events) {
|
|
264
|
-
entry.events[eventProp] = true;
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
257
|
notifyQueue.push(depKey);
|
|
268
258
|
// Prevent re-entrant notification loops
|
|
269
259
|
if (isNotifying)
|
|
270
260
|
return;
|
|
271
261
|
isNotifying = true;
|
|
262
|
+
const eventKeysToReset = [];
|
|
272
263
|
try {
|
|
273
264
|
while (notifyQueue.length > 0) {
|
|
274
265
|
const key = notifyQueue.shift();
|
|
266
|
+
// For event-style keys, set the flag before firing reactions
|
|
267
|
+
const dotIdx = key.indexOf('.');
|
|
268
|
+
if (dotIdx > -1) {
|
|
269
|
+
const id = key.substring(0, dotIdx);
|
|
270
|
+
const prop = key.substring(dotIdx + 1);
|
|
271
|
+
const entry = this._registry.get(id);
|
|
272
|
+
if (entry && prop in entry.events) {
|
|
273
|
+
entry.events[prop] = true;
|
|
274
|
+
eventKeysToReset.push({ entry, prop });
|
|
275
|
+
}
|
|
276
|
+
}
|
|
275
277
|
for (const [reaction, deps] of reactionDeps.entries()) {
|
|
276
278
|
if (deps.has(key)) {
|
|
277
279
|
reaction();
|
|
@@ -281,14 +283,11 @@ class PageState {
|
|
|
281
283
|
}
|
|
282
284
|
finally {
|
|
283
285
|
isNotifying = false;
|
|
284
|
-
// Reset event
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
entry.events[eventProp] = false;
|
|
290
|
-
});
|
|
291
|
-
}
|
|
286
|
+
// Reset all event flags after all reactions have run
|
|
287
|
+
for (const { entry, prop } of eventKeysToReset) {
|
|
288
|
+
queueMicrotask(() => {
|
|
289
|
+
entry.events[prop] = false;
|
|
290
|
+
});
|
|
292
291
|
}
|
|
293
292
|
}
|
|
294
293
|
}
|