]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
chore: Merge branch 'vapor' into edison/fix/vdomCompAttrFallthrough
authordaiwei <daiwei521@126.com>
Fri, 4 Jul 2025 03:46:33 +0000 (11:46 +0800)
committerdaiwei <daiwei521@126.com>
Fri, 4 Jul 2025 03:46:33 +0000 (11:46 +0800)
1  2 
packages/runtime-vapor/__tests__/vdomInterop.spec.ts

index 0000000000000000000000000000000000000000,08326d4d5d9babcc99c17dedffe0524557ff3998..c8e60566056beb194de6e840f6b36566b7184311
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,58 +1,84 @@@
+ import { defineComponent, h } from '@vue/runtime-dom'
+ import { makeInteropRender } from './_utils'
+ import { createComponent, defineVaporComponent } from '../src'
+ const define = makeInteropRender()
+ describe('vdomInterop', () => {
+   describe.todo('props', () => {})
+   describe.todo('emit', () => {})
+   describe.todo('slots', () => {})
+   describe.todo('provide', () => {})
+   describe.todo('inject', () => {})
+   describe.todo('template ref', () => {})
+   describe.todo('dynamic component', () => {})
+   describe('attribute fallthrough', () => {
++    it('should fallthrough attrs to vdom child', () => {
++      const VDomChild = defineComponent({
++        setup() {
++          return () => h('div')
++        },
++      })
++
++      const VaporChild = defineVaporComponent({
++        setup() {
++          return createComponent(
++            VDomChild as any,
++            { foo: () => 'vapor foo' },
++            null,
++            true,
++          )
++        },
++      })
++
++      const { html } = define({
++        setup() {
++          return () => h(VaporChild as any, { foo: 'foo', bar: 'bar' })
++        },
++      }).render()
++      expect(html()).toBe('<div foo="foo" bar="bar"></div>')
++    })
++
+     it('should not fallthrough emit handlers to vdom child', () => {
+       const VDomChild = defineComponent({
+         emits: ['click'],
+         setup(_, { emit }) {
+           return () => h('button', { onClick: () => emit('click') }, 'click me')
+         },
+       })
+       const fn = vi.fn()
+       const VaporChild = defineVaporComponent({
+         emits: ['click'],
+         setup() {
+           return createComponent(
+             VDomChild as any,
+             { onClick: () => fn },
+             null,
+             true,
+           )
+         },
+       })
+       const { host, html } = define({
+         setup() {
+           return () => h(VaporChild as any)
+         },
+       }).render()
+       expect(html()).toBe('<button>click me</button>')
+       const button = host.querySelector('button')!
+       button.dispatchEvent(new Event('click'))
+       // fn should be called once
+       expect(fn).toHaveBeenCalledTimes(1)
+     })
+   })
+ })