Skip to content

Fix dispatch wrapping for internal events #1283

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/event/dispatchEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<K extends EventType>(
target: Element,
type: K,
init?: EventTypeInit<K>,
) {
const event = createEvent(type, target, init)
wrapEvent(() => target.dispatchEvent(event), target)
): boolean {
return target.dispatchEvent(createEvent(type, target, init))
}