Skip to content

Conversation

@Sdju
Copy link

@Sdju Sdju commented Dec 26, 2025

Description

Fixes a bug in the ownKeys trap of the slots proxy where accessing slot.name would throw an error when a dynamic slot returns undefined (e.g., when using v-if with a false condition).

Reproduction: playground

Problem

When using dynamic slots with conditional rendering (via v-if), the ownKeys trap in dynamicSlotsProxyHandlers would attempt to access slot.name without first checking if slot is undefined. This caused a TypeError: Cannot read properties of undefined (reading 'name') when calling Object.keys(slots) or Reflect.ownKeys(slots) on a component instance with conditionally rendered slots.

Solution

Added a null check before accessing slot.name in the ownKeys trap handler. This ensures that when a dynamic slot source function returns undefined, it is properly skipped rather than causing an error.

Testing

  • Added a test case slots proxy ownKeys trap correctly reflects dynamic slot presence that verifies Reflect.ownKeys(instance.slots) correctly reflects the presence/absence of dynamic slots when toggled with v-if

@coderabbitai
Copy link

coderabbitai bot commented Dec 26, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Sdju
Copy link
Author

Sdju commented Dec 26, 2025

Additional Notes

I also checked for a similar issue in getKeysFromRawProps and resolveDynamicProps (used by useAttrs). While the same pattern exists where resolveFunctionSource can return undefined, the use of for...in loops safely handles null/undefined values without throwing errors (the loop body simply doesn't execute).

@edison1105 edison1105 added the scope: vapor related to vapor mode label Dec 28, 2025
@github-actions
Copy link

Size Report

Bundles

File Size Gzip Brotli
compiler-dom.global.prod.js 85.5 kB 30 kB 26.5 kB
runtime-dom.global.prod.js 108 kB 40.7 kB 36.6 kB
vue.global.prod.js 167 kB 60.7 kB 54.1 kB

Usages

Name Size Gzip Brotli
createApp (CAPI only) 48.3 kB 18.9 kB 17.3 kB
createApp 57.3 kB 22 kB 20.1 kB
createApp + vaporInteropPlugin 85.4 kB (+5 B) 31.9 kB (+1 B) 28.8 kB (-40 B)
createVaporApp 27.7 kB (+5 B) 10.6 kB (+1 B) 9.74 kB (-4 B)
createSSRApp 61.6 kB 23.9 kB 21.7 kB
defineCustomElement 63.3 kB 23.9 kB 21.8 kB
overall 72.1 kB 27.3 kB 24.9 kB

@pkg-pr-new
Copy link

pkg-pr-new bot commented Dec 28, 2025

Open in StackBlitz

@vue/compiler-core

pnpm add https://pkg.pr.new/@vue/compiler-core@14252
npm i https://pkg.pr.new/@vue/compiler-core@14252
yarn add https://pkg.pr.new/@vue/compiler-core@14252.tgz

@vue/compiler-dom

pnpm add https://pkg.pr.new/@vue/compiler-dom@14252
npm i https://pkg.pr.new/@vue/compiler-dom@14252
yarn add https://pkg.pr.new/@vue/compiler-dom@14252.tgz

@vue/compiler-sfc

pnpm add https://pkg.pr.new/@vue/compiler-sfc@14252
npm i https://pkg.pr.new/@vue/compiler-sfc@14252
yarn add https://pkg.pr.new/@vue/compiler-sfc@14252.tgz

@vue/compiler-ssr

pnpm add https://pkg.pr.new/@vue/compiler-ssr@14252
npm i https://pkg.pr.new/@vue/compiler-ssr@14252
yarn add https://pkg.pr.new/@vue/compiler-ssr@14252.tgz

@vue/compiler-vapor

pnpm add https://pkg.pr.new/@vue/compiler-vapor@14252
npm i https://pkg.pr.new/@vue/compiler-vapor@14252
yarn add https://pkg.pr.new/@vue/compiler-vapor@14252.tgz

@vue/reactivity

pnpm add https://pkg.pr.new/@vue/reactivity@14252
npm i https://pkg.pr.new/@vue/reactivity@14252
yarn add https://pkg.pr.new/@vue/reactivity@14252.tgz

@vue/runtime-core

pnpm add https://pkg.pr.new/@vue/runtime-core@14252
npm i https://pkg.pr.new/@vue/runtime-core@14252
yarn add https://pkg.pr.new/@vue/runtime-core@14252.tgz

@vue/runtime-dom

pnpm add https://pkg.pr.new/@vue/runtime-dom@14252
npm i https://pkg.pr.new/@vue/runtime-dom@14252
yarn add https://pkg.pr.new/@vue/runtime-dom@14252.tgz

@vue/runtime-vapor

pnpm add https://pkg.pr.new/@vue/runtime-vapor@14252
npm i https://pkg.pr.new/@vue/runtime-vapor@14252
yarn add https://pkg.pr.new/@vue/runtime-vapor@14252.tgz

@vue/server-renderer

pnpm add https://pkg.pr.new/@vue/server-renderer@14252
npm i https://pkg.pr.new/@vue/server-renderer@14252
yarn add https://pkg.pr.new/@vue/server-renderer@14252.tgz

@vue/shared

pnpm add https://pkg.pr.new/@vue/shared@14252
npm i https://pkg.pr.new/@vue/shared@14252
yarn add https://pkg.pr.new/@vue/shared@14252.tgz

vue

pnpm add https://pkg.pr.new/vue@14252
npm i https://pkg.pr.new/vue@14252
yarn add https://pkg.pr.new/vue@14252.tgz

@vue/compat

pnpm add https://pkg.pr.new/@vue/compat@14252
npm i https://pkg.pr.new/@vue/compat@14252
yarn add https://pkg.pr.new/@vue/compat@14252.tgz

commit: 225cbd7

@edison1105 edison1105 merged commit 1d376e0 into vuejs:minor Dec 28, 2025
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope: vapor related to vapor mode

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants