Skip to content

Commit

Permalink
fix: event target mismatch with global event (#1036)
Browse files Browse the repository at this point in the history
* fix: event target mismatch with global event

* test: dom doesn't throw

* chore: cleanup
  • Loading branch information
sheremet-va committed Mar 27, 2022
1 parent a0b03f9 commit a880d3f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/vitest/src/integrations/env/utils.ts
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
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()
})

0 comments on commit a880d3f

Please sign in to comment.