mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
refactor(core): Add an ngOnDestroy to GlobalEventDelegation. (#56762)
It seems that this makes test libs that contain > 1 test file pass. PR Close #56762
This commit is contained in:
committed by
Jessica Janiuk
parent
9cbfc6bf25
commit
fdd8fb0e66
@@ -20,6 +20,7 @@ import {Attribute} from '@angular/core/primitives/event-dispatch';
|
||||
import {Injectable, InjectionToken, Injector, inject} from './di';
|
||||
import {RElement} from './render3/interfaces/renderer_dom';
|
||||
import {EVENT_REPLAY_ENABLED_DEFAULT, IS_EVENT_REPLAY_ENABLED} from './hydration/tokens';
|
||||
import {OnDestroy} from './interface/lifecycle_hooks';
|
||||
|
||||
declare global {
|
||||
interface Element {
|
||||
@@ -82,9 +83,13 @@ export const GLOBAL_EVENT_DELEGATION = new InjectionToken<GlobalEventDelegation>
|
||||
* `provideGlobalEventDelegation` is called.
|
||||
*/
|
||||
@Injectable()
|
||||
export class GlobalEventDelegation {
|
||||
export class GlobalEventDelegation implements OnDestroy {
|
||||
private eventContractDetails = inject(JSACTION_EVENT_CONTRACT);
|
||||
|
||||
ngOnDestroy() {
|
||||
this.eventContractDetails.instance?.cleanUp();
|
||||
}
|
||||
|
||||
supports(eventName: string): boolean {
|
||||
return isSupportedEvent(eventName);
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ function configureTestingModule(components: unknown[]) {
|
||||
|
||||
describe('event dispatch', () => {
|
||||
let fixture: ComponentFixture<unknown>;
|
||||
afterEach(() => fixture.debugElement.injector.get(ɵJSACTION_EVENT_CONTRACT).instance?.cleanUp());
|
||||
|
||||
it(`executes an onclick handler`, async () => {
|
||||
const onClickSpy = jasmine.createSpy();
|
||||
|
||||
Reference in New Issue
Block a user