]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(vdomInterop): handle forwarded vapor slots during render VDOM slot
authordaiwei <daiwei521@126.com>
Fri, 30 May 2025 08:27:02 +0000 (16:27 +0800)
committerdaiwei <daiwei521@126.com>
Fri, 30 May 2025 09:12:43 +0000 (17:12 +0800)
packages/runtime-vapor/src/componentProps.ts
packages/runtime-vapor/src/vdomInterop.ts

index a5e9daad229ca25c684614de03d195ebc2aee985..7a0e9ed9286a029c992ab43fc3deb06d88e4ef7d 100644 (file)
@@ -210,7 +210,8 @@ export function hasAttrFromRawProps(rawProps: RawProps, key: string): boolean {
   if (dynamicSources) {
     let i = dynamicSources.length
     while (i--) {
-      if (hasOwn(resolveSource(dynamicSources[i]), key)) {
+      const source = resolveSource(dynamicSources[i])
+      if (source && hasOwn(source, key)) {
         return true
       }
     }
index 77228fd72a02fe85a5496daf7d89bc37e197a4d2..e7c7e02e0bdb5bb904af487277d9f22325f6a5bb 100644 (file)
@@ -26,7 +26,14 @@ import {
   mountComponent,
   unmountComponent,
 } from './component'
-import { type Block, VaporFragment, insert, remove } from './block'
+import {
+  type Block,
+  VaporFragment,
+  insert,
+  isFragment,
+  isValidBlock,
+  remove,
+} from './block'
 import { EMPTY_OBJ, extend, isFunction } from '@vue/shared'
 import { type RawProps, rawPropsProxyHandlers } from './componentProps'
 import type { RawSlots, VaporSlot } from './componentSlots'
@@ -230,7 +237,24 @@ function renderVDOMSlot(
           isFunction(name) ? name() : name,
           props,
         )
-        if ((vnode.children as any[]).length) {
+        let isValidSlotContent
+        let children = vnode.children as any[]
+
+        // TODO add tests
+        // handle forwarded vapor slot
+        let vaporSlot
+        if (children.length === 1 && (vaporSlot = children[0].vs)) {
+          const block = vaporSlot.slot(props)
+          isValidSlotContent =
+            isValidBlock(block) ||
+            // if block is a vapor fragment with insert, it indicates a forwarded VDOM slot
+            (isFragment(block) && block.insert)
+        }
+        // vnode children
+        else {
+          isValidSlotContent = children.length > 0
+        }
+        if (isValidSlotContent) {
           if (fallbackNodes) {
             remove(fallbackNodes, parentNode)
             fallbackNodes = undefined