From 9224f9b0439c4730926bb604960ef90231b61e00 Mon Sep 17 00:00:00 2001 From: Jessica Janiuk Date: Mon, 14 Oct 2024 16:21:51 -0400 Subject: [PATCH] refactor(core): Add mouseover to hover dom triggers (#58197) Unfortunately mouseenter is a synthetic event, meaning it does not bubble in the same ways. So mouseover needs to be included in this list in order to get proper browser replayability of the mouse hovering events. PR Close #58197 --- packages/core/src/defer/dom_triggers.ts | 4 ++-- packages/core/test/acceptance/defer_spec.ts | 23 ++++++++++++++++----- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/packages/core/src/defer/dom_triggers.ts b/packages/core/src/defer/dom_triggers.ts index 5a1b74d4901d3..cbe727e1216ce 100644 --- a/packages/core/src/defer/dom_triggers.ts +++ b/packages/core/src/defer/dom_triggers.ts @@ -47,10 +47,10 @@ const interactionTriggers = new WeakMap(); const viewportTriggers = new WeakMap(); /** Names of the events considered as interaction events. */ -const interactionEventNames = ['click', 'keydown'] as const; +export const interactionEventNames = ['click', 'keydown'] as const; /** Names of the events considered as hover events. */ -const hoverEventNames = ['mouseenter', 'focusin'] as const; +export const hoverEventNames = ['mouseenter', 'mouseover', 'focusin'] as const; /** `IntersectionObserver` used to observe `viewport` triggers. */ let intersectionObserver: IntersectionObserver | null = null; diff --git a/packages/core/test/acceptance/defer_spec.ts b/packages/core/test/acceptance/defer_spec.ts index bdb0dec480114..ce10820403cb5 100644 --- a/packages/core/test/acceptance/defer_spec.ts +++ b/packages/core/test/acceptance/defer_spec.ts @@ -3027,8 +3027,9 @@ describe('@defer', () => { fixture.detectChanges(); flush(); - expect(spy).toHaveBeenCalledTimes(2); + expect(spy).toHaveBeenCalledTimes(3); expect(spy).toHaveBeenCalledWith('mouseenter', jasmine.any(Function), jasmine.any(Object)); + expect(spy).toHaveBeenCalledWith('mouseover', jasmine.any(Function), jasmine.any(Object)); expect(spy).toHaveBeenCalledWith('focusin', jasmine.any(Function), jasmine.any(Object)); })); @@ -3062,8 +3063,9 @@ describe('@defer', () => { fixture.componentInstance.renderBlock = false; fixture.detectChanges(); - expect(spy).toHaveBeenCalledTimes(2); + expect(spy).toHaveBeenCalledTimes(3); expect(spy).toHaveBeenCalledWith('mouseenter', jasmine.any(Function), jasmine.any(Object)); + expect(spy).toHaveBeenCalledWith('mouseover', jasmine.any(Function), jasmine.any(Object)); expect(spy).toHaveBeenCalledWith('focusin', jasmine.any(Function), jasmine.any(Object)); })); @@ -3098,8 +3100,9 @@ describe('@defer', () => { fixture.componentInstance.renderBlock = false; fixture.detectChanges(); - expect(spy).toHaveBeenCalledTimes(2); + expect(spy).toHaveBeenCalledTimes(3); expect(spy).toHaveBeenCalledWith('mouseenter', jasmine.any(Function), jasmine.any(Object)); + expect(spy).toHaveBeenCalledWith('mouseover', jasmine.any(Function), jasmine.any(Object)); expect(spy).toHaveBeenCalledWith('focusin', jasmine.any(Function), jasmine.any(Object)); })); @@ -4021,12 +4024,17 @@ describe('@defer', () => { fixture.detectChanges(); // Verify that trigger element is cleaned up. - expect(triggerSpy).toHaveBeenCalledTimes(2); + expect(triggerSpy).toHaveBeenCalledTimes(3); expect(triggerSpy).toHaveBeenCalledWith( 'mouseenter', jasmine.any(Function), jasmine.any(Object), ); + expect(triggerSpy).toHaveBeenCalledWith( + 'mouseover', + jasmine.any(Function), + jasmine.any(Object), + ); expect(triggerSpy).toHaveBeenCalledWith( 'focusin', jasmine.any(Function), @@ -4034,12 +4042,17 @@ describe('@defer', () => { ); // Verify that prefetch trigger element is cleaned up. - expect(prefetchSpy).toHaveBeenCalledTimes(2); + expect(prefetchSpy).toHaveBeenCalledTimes(3); expect(prefetchSpy).toHaveBeenCalledWith( 'mouseenter', jasmine.any(Function), jasmine.any(Object), ); + expect(prefetchSpy).toHaveBeenCalledWith( + 'mouseover', + jasmine.any(Function), + jasmine.any(Object), + ); expect(prefetchSpy).toHaveBeenCalledWith( 'focusin', jasmine.any(Function),