customElementCasing.spec.ts 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import { createApp } from '../src'
  2. // https://github.com/vuejs/docs/pull/1890
  3. // https://github.com/vuejs/core/issues/5401
  4. // https://github.com/vuejs/docs/issues/1708
  5. test('custom element event casing', () => {
  6. customElements.define(
  7. 'custom-event-casing',
  8. class Foo extends HTMLElement {
  9. connectedCallback() {
  10. this.dispatchEvent(new Event('camelCase'))
  11. this.dispatchEvent(new Event('CAPScase'))
  12. this.dispatchEvent(new Event('PascalCase'))
  13. }
  14. },
  15. )
  16. const container = document.createElement('div')
  17. document.body.appendChild(container)
  18. const handler = vi.fn()
  19. const handler2 = vi.fn()
  20. createApp({
  21. template: `
  22. <custom-event-casing
  23. @camelCase="handler"
  24. @CAPScase="handler"
  25. @PascalCase="handler"
  26. v-on="{
  27. camelCase: handler2,
  28. CAPScase: handler2,
  29. PascalCase: handler2
  30. }" />`,
  31. methods: {
  32. handler,
  33. handler2,
  34. },
  35. }).mount(container)
  36. expect(handler).toHaveBeenCalledTimes(3)
  37. expect(handler2).toHaveBeenCalledTimes(3)
  38. })