Skip to content
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

fix: event target mismatch with global event #1036

Merged
merged 3 commits into from
Mar 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/vitest/src/integrations/env/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { KEYS } from './jsdom-keys'

const allowRewrite = new Set([
'Event',
'EventTarget',
])

export function getWindowKeys(global: any, win: any) {
Expand Down
6 changes: 6 additions & 0 deletions test/core/test/dom.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,9 @@ it('jsdom', () => {

expect(dom.outerHTML).toEqual('<a href="https://vitest.dev">&lt;Vitest&gt;</a>')
})

it('dispatchEvent doesn\'t throw', () => {
const target = new EventTarget()
const event = new Event('click')
expect(() => target.dispatchEvent(event)).not.toThrow()
})