Skip to content

Commit 67bb310

Browse files
iterianiAndrewKushnir
authored andcommitted
refactor(core): Fix timing of removal of jsaction attribute to be after event replay. (angular#55696)
This otherwise leads to bugs where, by the time replay needs the attribute, hydration happens and it's gone. PR Close angular#55696
1 parent a9460d0 commit 67bb310

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

packages/core/src/hydration/event_replay.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ declare global {
3636
}
3737

3838
const JSACTION_ATTRIBUTE = 'jsaction';
39+
const removeJsactionQueue: RElement[] = [];
3940

4041
/**
4142
* Returns a set of providers required to setup support for event replay.
@@ -52,7 +53,9 @@ export function withEventReplay(): Provider[] {
5253
useValue: () => {
5354
setDisableEventReplayImpl((el: RElement) => {
5455
if (el.hasAttribute(JSACTION_ATTRIBUTE)) {
55-
el.removeAttribute(JSACTION_ATTRIBUTE);
56+
// We don't immediately remove the attribute here because
57+
// we need it for replay that happens after hydration.
58+
removeJsactionQueue.push(el);
5659
}
5760
});
5861
},
@@ -79,6 +82,10 @@ export function withEventReplay(): Provider[] {
7982
setEventReplayer(dispatcher);
8083
// Event replay is kicked off as a side-effect of executing this function.
8184
registerDispatcher(eventContract, dispatcher);
85+
for (const el of removeJsactionQueue) {
86+
el.removeAttribute(JSACTION_ATTRIBUTE);
87+
}
88+
removeJsactionQueue.length = 0;
8289
}
8390
});
8491
};

0 commit comments

Comments
 (0)