Skip to content

compiler-core: :key expression not prefixed when element has v-memo without v-for (ReferenceError at runtime) #14920

Closed

Description

@adnesvetaev

Version

3.5.35

Reproduction link

play.vuejs.org/

Steps to reproduce

Open the playground link; it throws on load.
The trigger is v-memo + dynamic :key on a plain element without v-for, where the key references a prop

What is expected?

:key expression is prefixed like any other (__props.updateKey / _ctx.updateKey), as in ≤3.5.12

What is actually happening?

transformExpression skips the :key expression whenever the element has v-memo (the !(memo && arg.content === 'key') check added in 99009ee / PR #12014), assuming transformFor processed it eagerly — but that only happens when v-for is also present.

Plain elements fall through → unprefixed key → ReferenceError at runtime


This happened after vue version update.

We hit this in a component library's scroll-container component. It renders custom scrollbars, so its reactive scroll state changes on every scroll frame; to keep large slotted content (e.g. a table body with thousands of cells) from re-rendering on each frame, the content wrapper uses v-memo="[updateKey]" with :key="updateKey" on the same element — "freeze this subtree, and when the parent bumps updateKey (data reload, layout change), rebuild it from scratch instead of diffing."

This compiled and ran correctly up to compiler 3.5.12; from 3.5.13 the generated render function references the key as a bare identifier and every page using the component throws ReferenceError on first render.

Current workaround: v-bind="{ key: updateKey }" instead of :key="updateKey", which bypasses the skipped code path and produces a correctly prefixed expression.

Activity

  1. added
    has workaround
    🔨 p3-minor-bug
    on Jun 5, 2026
  2. added a commit that references this issue on Jun 11, 2026
    68e978e
  3. locked and limited conversation to collaborators on Jun 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    🔨 p3-minor-bughas workaroundscope: compiler

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions