From 5a98950fcae1ce7f24637f1917cb5ed0564558ec Mon Sep 17 00:00:00 2001 From: Michael Molisani Date: Sun, 13 Apr 2025 17:13:08 -0400 Subject: [PATCH] Fix dispatch wrapping for internal events --- src/event/dispatchEvent.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/event/dispatchEvent.ts b/src/event/dispatchEvent.ts index 4627296d..1a630714 100644 --- a/src/event/dispatchEvent.ts +++ b/src/event/dispatchEvent.ts @@ -63,11 +63,15 @@ export function dispatchEvent( return wrapEvent(() => target.dispatchEvent(event), target) } +/** + * Dispatch a DOM event without wrapping it with the configured wrapper. + * This is used internally to trigger events that are not triggered natively by JSDOM. + * These should not be wrapped explicitly as they are already executed in the triggering wrapped scope. + */ export function dispatchDOMEvent( target: Element, type: K, init?: EventTypeInit, -) { - const event = createEvent(type, target, init) - wrapEvent(() => target.dispatchEvent(event), target) +): boolean { + return target.dispatchEvent(createEvent(type, target, init)) }