Skip to content

fix(vue): add no v-citry-vue-owned marker inside v-pre - #514

Merged
JuroOravec merged 1 commit into
mainfrom
fix/no-vue-owned-marker-in-v-pre
Oct 28, 2026
Merged

JuroOravec merged 1 commit into
mainfrom
fix/no-vue-owned-marker-in-v-pre

Conversation

@JuroOravec

Copy link
Copy Markdown
Member

Closes #414.

What this fixes

In a component that uses Vue, a form control inside or carrying v-pre (<input :value>, <option :selected>, <select>, <textarea>) got a stray v-citry-vue-owned attribute in the page. Under v-pre, Vue reads the element as written, so :value there is plain text and owns nothing.

A new helper, writes_vue_owned_marker(tag, *, under_v_pre) in _vue/capture.py, decides whether to add the marker. Every walk that writes it now tracks whether the element has v-pre or sits inside one:

  • direct_capture.py, the path that writes pages;
  • static_template.py, the template citry check compiles;
  • compiler.py, the composer that builds a Vue template from a PreparedView.

No Rust change is needed: the Rust server renderer only handles the compiled directive, which no longer appears under v-pre.

Three sibling bugs, found by the sweep

Each of these failed on main:

  • A keyed transparent component inside v-pre (<c-provide #c-key>) raised VueCompilerDiagnosticsError. The v-pre element's contents are now written as one block of HTML.
  • v-pre at the root of a component with css_data() raised ELEMENT_ATTRS_BINDING_MISMATCH, because Citry adds the root attribute through a Vue binding. Citry now compiles that root itself. If the root also carries its own Vue attribute, the error says the root is why, and suggests wrapping it. It says so only when that is the whole reason.
  • Copied slot content (slot content a component writes for another component it does not enclose) was refused when it held :x, @x or v-text under v-pre. Only ref, which Vue 3.5 still registers under v-pre, now counts.

Evidence

  • Each new test fails on main and passes now. They cover:
    • the marker on the element itself, nested, inside a table and inside <c-provide>;
    • the marker kept outside and after the v-pre block;
    • the keyed and root cases, and both error messages;
    • citry check/render parity;
    • copied slot content.
  • 2,436 tests pass across test_vue*.py, test_check*.py, markup lint, browser analysis and the render walkers.
  • A new Chromium test, test_v_pre_form_controls_hydrate_without_an_ownership_marker, shows no hydration mismatch, with 2 markers in the DOM on main and 0 now. The reviewer also hydrated 9 more cases in Chromium with no mismatch: css_data() roots, #c-key, nested v-pre and <input v-pre>.
  • The reviewer measured no render cost on 200 ordinary rows (assemble_typed_render median 42.67/41.92 ms against 42.48/41.91 ms).
  • ruff is clean, and mypy too, including --platform linux.
  • An independent review is folded in: the root error's advice and the wording.
  • Cargo is left to CI.

Not in this PR (found by the sweep)

  • Rust parser: the template parser rejects Vue-only mistakes inside v-pre when a template loads, such as v-once, @click.bogus and <transition>.
  • Rust compiler (vize): it still compiles <slot>, <component is>, <teleport> and <keep-alive> inside v-pre as live Vue, which Vue 3.5 does not.
  • citry check and the editor: browser_expressions() has no v-pre filter, so they report unknown variables for Vue expressions under v-pre.
  • Duplicate-id lint: a v-if under v-pre is still treated as conditional.
  • citry check vs render: when Citry compiles a v-pre element itself (because it holds Citry values), the check template still differs from the render. That predates this PR.

🤖 Generated with Claude Code

Vue compiles nothing under `v-pre`, so a `:value` or `:selected` there
is a plain attribute, not a binding. Citry still added its
`v-citry-vue-owned` marker to form controls there, and Vue wrote the
marker into the page. One helper, `writes_vue_owned_marker`, now skips
the marker for an element under `v-pre` (its own or an ancestor's) in
the render assembler, the composer that builds a Vue template from a `PreparedView`, and the template that
`citry check` compiles.

The sweep for other places that treat Vue syntax under `v-pre` as live
fixed three more in the same walk:
- a transparent component with `#c-key` inside `v-pre` failed to compile,
  because its keyed `<template>` wrapper sat where Vue does not read it;
  its contents are now written as one block of HTML;
- a `v-pre` element at the root of a component with `css_data()` failed
  to compile, because Citry adds the root attribute with a Vue binding;
  Citry now compiles that root itself, and an error names the reason when
  the root carries its own Vue attribute;
- slot content copied to another component was refused when it held Vue
  attributes under `v-pre`; only `ref`, which Vue still reads, now counts.

Closes #414.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.

A v-pre element's :value gets a stray v-citry-vue-owned attribute

1 participant