refactor(core): allow passing passive option to addEvent (#58316)

For scroll-blocking events like 'touchstart', 'touchmove', 'wheel' and 'mousewheel',
if passive option is not specified when adding the event listener, browser may give
a violation warning.

This PR allows us to set the passive option when calling event lib's addEvent().

PR Close #58316
This commit is contained in:
Yong Su 2024-10-22 16:02:55 -07:00 committed by Alex Rickabaugh
parent f34268161b
commit d7283bf740

View file

@ -28,7 +28,7 @@ export interface EarlyJsactionDataContainer {
// @public
export class EventContract implements UnrenamedEventContract {
constructor(containerManager: EventContractContainerManager);
addEvent(eventType: string, prefixedEventType?: string): void;
addEvent(eventType: string, prefixedEventType?: string, passive?: boolean): void;
cleanUp(): void;
ecrd(dispatcher: Dispatcher, restriction: Restriction): void;
handler(eventType: string): EventHandler | undefined;
@ -42,7 +42,7 @@ export class EventContract implements UnrenamedEventContract {
// @public
export class EventContractContainer implements EventContractContainerManager {
constructor(element: Element);
addEventListener(eventType: string, getHandler: (element: Element) => (event: Event) => void): void;
addEventListener(eventType: string, getHandler: (element: Element) => (event: Event) => void, passive?: boolean): void;
cleanUp(): void;
// (undocumented)
readonly element: Element;