fix(runtime-vapor): correctly check slot existence in ownKeys#14252
fix(runtime-vapor): correctly check slot existence in ownKeys#14252edison1105 merged 1 commit intovuejs:minorfrom
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the ✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Additional NotesI also checked for a similar issue in |
Size ReportBundles
Usages
|
@vue/compiler-core
@vue/compiler-dom
@vue/compiler-sfc
@vue/compiler-ssr
@vue/compiler-vapor
@vue/reactivity
@vue/runtime-core
@vue/runtime-dom
@vue/runtime-vapor
@vue/server-renderer
@vue/shared
vue
@vue/compat
commit: |
Description
Fixes a bug in the
ownKeystrap of the slots proxy where accessingslot.namewould throw an error when a dynamic slot returnsundefined(e.g., when usingv-ifwith afalsecondition).Reproduction: playground
Problem
When using dynamic slots with conditional rendering (via
v-if), theownKeystrap indynamicSlotsProxyHandlerswould attempt to accessslot.namewithout first checking ifslotisundefined. This caused aTypeError: Cannot read properties of undefined (reading 'name')when callingObject.keys(slots)orReflect.ownKeys(slots)on a component instance with conditionally rendered slots.Solution
Added a null check before accessing
slot.namein theownKeystrap handler. This ensures that when a dynamic slot source function returnsundefined, it is properly skipped rather than causing an error.Testing
slots proxy ownKeys trap correctly reflects dynamic slot presencethat verifiesReflect.ownKeys(instance.slots)correctly reflects the presence/absence of dynamic slots when toggled withv-if