]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(runtime-vapor): handle vapor attrs fallthrough to vdom component (#13551)
authoredison <daiwei521@126.com>
Tue, 2 Sep 2025 06:05:16 +0000 (14:05 +0800)
committerGitHub <noreply@github.com>
Tue, 2 Sep 2025 06:05:16 +0000 (14:05 +0800)
packages/runtime-vapor/__tests__/vdomInterop.spec.ts
packages/runtime-vapor/src/component.ts

index c7cc41d4fc85d939ccd1206b9f5d537a3b434ce1..dd25f06aab8bcaeaa5a1b163f3b9f043050c1cd0 100644 (file)
@@ -214,6 +214,32 @@ describe('vdomInterop', () => {
   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'],
index da57882c49de648cd4abdda7c133af7cc390b262..08fd881e9596ea578114a8c6d1b64ce28bddde10 100644 (file)
@@ -149,19 +149,6 @@ export function createComponent(
     resetInsertionState()
   }
 
-  // vdom interop enabled and component is not an explicit vapor component
-  if (appContext.vapor && !component.__vapor) {
-    const frag = appContext.vapor.vdomMount(
-      component as any,
-      rawProps,
-      rawSlots,
-    )
-    if (!isHydrating && _insertionParent) {
-      insert(frag, _insertionParent, _insertionAnchor)
-    }
-    return frag
-  }
-
   if (
     isSingleRoot &&
     component.inheritAttrs !== false &&
@@ -180,6 +167,19 @@ export function createComponent(
     }
   }
 
+  // vdom interop enabled and component is not an explicit vapor component
+  if (appContext.vapor && !component.__vapor) {
+    const frag = appContext.vapor.vdomMount(
+      component as any,
+      rawProps,
+      rawSlots,
+    )
+    if (!isHydrating && _insertionParent) {
+      insert(frag, _insertionParent, _insertionAnchor)
+    }
+    return frag
+  }
+
   const instance = new VaporComponentInstance(
     component,
     rawProps as RawProps,