Просмотр исходного кода

fix(runtime-core): ensure slot resolution returns undefined explicitly

daiwei 3 месяцев назад
Родитель
Сommit
22577787b1

+ 2 - 1
packages/runtime-core/src/component.ts

@@ -1121,7 +1121,8 @@ const createSlotsProxyHandlers = (
     // in-DOM templates use kebab-case slot names, only relevant in browser
     return (
       target[key as string] ||
-      (__BROWSER__ && typeof key === 'string' && target[hyphenate(key)])
+      (__BROWSER__ && typeof key === 'string' && target[hyphenate(key)]) ||
+      undefined
     )
   },
 })

+ 1 - 1
packages/runtime-core/src/helpers/renderSlot.ts

@@ -54,7 +54,7 @@ export function renderSlot(
   }
 
   // in-DOM templates use kebab-case slot names, only relevant in browser
-  let slot = slots[name] || (__BROWSER__ && slots[hyphenate(name)])
+  let slot = slots[name] || (__BROWSER__ && slots[hyphenate(name)]) || undefined
 
   if (__DEV__ && slot && slot.length > 1) {
     warn(