fix(custom-element): fix event listeners with capital letter event names on custom elements
close https://github.com/vuejs/docs/issues/1708 close https://github.com/vuejs/docs/pull/1890
This commit is contained in:
42
packages/vue/__tests__/customElementCasing.spec.ts
Normal file
42
packages/vue/__tests__/customElementCasing.spec.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
import { createApp } from '../src'
|
||||
|
||||
// https://github.com/vuejs/docs/pull/1890
|
||||
// https://github.com/vuejs/core/issues/5401
|
||||
// https://github.com/vuejs/docs/issues/1708
|
||||
test('custom element event casing', () => {
|
||||
customElements.define(
|
||||
'custom-event-casing',
|
||||
class Foo extends HTMLElement {
|
||||
connectedCallback() {
|
||||
this.dispatchEvent(new Event('camelCase'))
|
||||
this.dispatchEvent(new Event('CAPScase'))
|
||||
this.dispatchEvent(new Event('PascalCase'))
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
const container = document.createElement('div')
|
||||
document.body.appendChild(container)
|
||||
|
||||
const handler = jest.fn()
|
||||
const handler2 = jest.fn()
|
||||
createApp({
|
||||
template: `
|
||||
<custom-event-casing
|
||||
@camelCase="handler"
|
||||
@CAPScase="handler"
|
||||
@PascalCase="handler"
|
||||
v-on="{
|
||||
camelCase: handler2,
|
||||
CAPScase: handler2,
|
||||
PascalCase: handler2
|
||||
}" />`,
|
||||
methods: {
|
||||
handler,
|
||||
handler2
|
||||
}
|
||||
}).mount(container)
|
||||
|
||||
expect(handler).toHaveBeenCalledTimes(3)
|
||||
expect(handler2).toHaveBeenCalledTimes(3)
|
||||
})
|
||||
Reference in New Issue
Block a user