Skip to content

Commit 330c24a

Browse files
thePunderWomanmmalerba
authored andcommitted
fix(core): prevent invoking replay listeners on disconnected nodes (#60103)
This prevents replay from happening on nodes that have been removed from the DOM. fixes: #59841 PR Close #60103
1 parent ada75b6 commit 330c24a

File tree

1 file changed

+2
-12
lines changed

1 file changed

+2
-12
lines changed

packages/core/src/event_delegation_utils.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// tslint:disable:no-duplicate-imports
1010
import {EventContract} from '@angular/core/primitives/event-dispatch';
1111
import {Attribute} from '@angular/core/primitives/event-dispatch';
12-
import {InjectionToken, Injector} from './di';
12+
import {InjectionToken} from './di';
1313
import {RElement} from './render3/interfaces/renderer_dom';
1414

1515
export const DEFER_BLOCK_SSR_ID_ATTRIBUTE = 'ngb';
@@ -20,16 +20,6 @@ declare global {
2020
}
2121
}
2222

23-
export function invokeRegisteredDelegationListeners(event: Event) {
24-
const handlerFns = (event.currentTarget as Element)?.__jsaction_fns?.get(event.type);
25-
if (!handlerFns) {
26-
return;
27-
}
28-
for (const handler of handlerFns) {
29-
handler(event);
30-
}
31-
}
32-
3323
export function setJSActionAttributes(
3424
nativeElement: Element,
3525
eventTypes: string[],
@@ -112,7 +102,7 @@ export const JSACTION_EVENT_CONTRACT = new InjectionToken<EventContractDetails>(
112102

113103
export function invokeListeners(event: Event, currentTarget: Element | null) {
114104
const handlerFns = currentTarget?.__jsaction_fns?.get(event.type);
115-
if (!handlerFns) {
105+
if (!handlerFns || !currentTarget?.isConnected) {
116106
return;
117107
}
118108
for (const handler of handlerFns) {

0 commit comments

Comments
 (0)