refactor: adjust event options handling to be JSX friendly

This commit is contained in:
Evan You
2020-07-14 13:20:59 -04:00
parent e3d30ba26f
commit 00ab9e2e85
6 changed files with 33 additions and 37 deletions

View File

@@ -61,7 +61,7 @@ describe(`runtime-dom: events patching`, () => {
const el = document.createElement('div')
const event = new Event('click')
const fn = jest.fn()
patchProp(el, 'onClick.once.capture', null, fn)
patchProp(el, 'onClickOnceCapture', null, fn)
el.dispatchEvent(event)
await timeout()
el.dispatchEvent(event)
@@ -73,13 +73,17 @@ describe(`runtime-dom: events patching`, () => {
const el = document.createElement('div')
const event = new Event('click')
const fn = jest.fn()
patchProp(el, 'onClick.capture', null, fn)
patchProp(el, 'onClick.capture', fn, null)
patchProp(el, 'onClickCapture', null, fn)
el.dispatchEvent(event)
await timeout()
expect(fn).toHaveBeenCalledTimes(1)
patchProp(el, 'onClickCapture', fn, null)
el.dispatchEvent(event)
await timeout()
el.dispatchEvent(event)
await timeout()
expect(fn).not.toHaveBeenCalled()
expect(fn).toHaveBeenCalledTimes(1)
})
it('should support native onclick', async () => {