Skip to content

fix(compiler-vapor): ignore key on <template> v-if branches - #15509

Merged
edison1105 merged 1 commit into
vuejs:minorfrom
ValentinYoushkevich:fix/vapor-template-if-key
Sep 14, 2026
Merged

edison1105 merged 1 commit into
vuejs:minorfrom
ValentinYoushkevich:fix/vapor-template-if-key

Conversation

@ValentinYoushkevich

Copy link
Copy Markdown
Contributor

A :key on <template v-if> crashes the Vapor compiler with Maximum call stack size exceeded, while VDOM just renders the branch.

Nothing fancy is needed to hit it, a <template v-if="show" :key="id"> with a couple of children is enough, and the same happens on v-else-if / v-else branches. The whole SFC fails to compile. Playground

transformKey wraps a <template> that has another structural directive, and wrapTemplate only keeps directives on the wrapper by prop.name. A :key binding is named bind, so both v-if and :key move to the inner <template>, which gets wrapped again, and so on. It looks like this came with #14413, before that maybeMarkKeyedBlock skipped v-if branches and the children of <template v-if>.

In VDOM this key is ignored: createIfBranch renders the template's children and userKey is only used for the same key check, so changing it doesn't remount anything. I made transformKey skip <template> nodes with v-if / v-else-if / v-else, the generated code is now the same as without the key.

A dynamic `:key` on `<template v-if>` / `v-else-if` / `v-else` made
transformKey re-wrap the branch forever, crashing the compiler with
"Maximum call stack size exceeded". VDOM ignores this key, so skip it.
@coderabbitai

coderabbitai Bot commented Sep 14, 2026

Copy link
Copy Markdown

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.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: dd0e7f2d-7b38-4a6b-8ff6-0bb06934d573

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

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

@pkg-pr-new

pkg-pr-new Bot commented Sep 14, 2026

Copy link
Copy Markdown

Open in StackBlitz

@vue/compiler-core

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

@vue/compiler-dom

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

@vue/compiler-sfc

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

@vue/compiler-ssr

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

@vue/compiler-vapor

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

@vue/reactivity

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

@vue/runtime-core

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

@vue/runtime-dom

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

@vue/runtime-vapor

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

@vue/server-renderer

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

@vue/shared

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

vue

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

@vue/compat

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

commit: 07d6785

@github-actions

Copy link
Copy Markdown

Size Report

Bundles

File Size Gzip Brotli
compiler-dom.global.prod.js 87.2 kB 30.6 kB 26.9 kB
runtime-dom.global.prod.js 116 kB 43.7 kB 39.1 kB
vue.global.prod.js 176 kB 63.9 kB 56.8 kB

Usages

Name Size Gzip Brotli
createApp (CAPI only) 53.2 kB 20.6 kB 18.8 kB
createApp 61.9 kB 23.8 kB 21.7 kB
createApp + vaporInteropPlugin 119 kB 42.8 kB 38.5 kB
createVaporApp 30.5 kB 11.7 kB 10.8 kB
createSSRApp 67.1 kB 25.9 kB 23.5 kB
createVaporSSRApp 36.7 kB 14 kB 12.8 kB
defineCustomElement 68.5 kB 25.8 kB 23.5 kB
defineVaporCustomElement 45.9 kB 16.7 kB 15.3 kB
overall 77.3 kB 29.4 kB 26.6 kB

@edison1105
edison1105 merged commit 01dba84 into vuejs:minor Sep 14, 2026
15 checks passed
@ValentinYoushkevich
ValentinYoushkevich deleted the fix/vapor-template-if-key branch September 17, 2026 04:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants