Repository navigation
fix: read v-pre content as plain, as Vue 3.5 does - #525
Merged
Merged
Conversation
Inside v-pre, Vue reads directives as plain attributes and tags as plain elements. Citry's template parser still ran its Vue-only checks there, so v-once, <transition>, or @click.bogus inside v-pre failed to load, and vize compiled <slot>, <component is>, <teleport>, <keep-alive>, and <transition> inside v-pre as live Vue. - The template parser skips the Vue-only checks for an HTML element that carries v-pre or sits inside one, and rejects v-pre written with an argument or modifiers. Citry tags keep their checks, and Vue slot syntax on a component's direct child keeps its check inside v-pre. - vize's S2 lane (patched, now 0.420.0+citry.7) keeps those tags plain inside v-pre and on the element that opens it, and drops `is` from a plain <component>, matching @vue/compiler-dom 3.5.42. - Citry's Vue compiler refuses (V_PRE_NEEDS_S2_LANE) a v-pre template that only vize's fallback lane would compile, since that lane still reads those tags as live (#519), and its metadata walk no longer reports a <slot> or fill under v-pre as an outlet. - v-once and v-memo inside v-pre render as plain attributes; elsewhere they are still refused. - When v-pre sits on a Vue-typed tag whose contents hold Citry values, rendering fails with advice to put v-pre on an element around it. Fixes #515. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Oct 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this fixes
Vue 3.5 reads an element with
v-pre, and everything inside it, as written: directives stay plain attributes and tags stay plain elements. Citry differed in two places (#515):v-pre(v-once,<transition>,@click.bogus), so templates Vue accepts failed to load.v-preas live Vue:<slot>as an outlet,<component is>as a dynamic component,<teleport>,<keep-alive>, and<transition>as built-ins.Changes
parser.rs): a per-entryin_v_preflag on the tag stack. For an HTML element carryingv-preor inside one, the Vue-only checks are skipped: listener modifiers, reserved names,v-once/v-memo, directive shapes, Vue built-in tags, and a Vue binding beside a Python value. The order of the remaining checks is unchanged. Citry tags (<c-*>) keep all their checks, and Vue slot syntax on a component's direct child keeps its check insidev-pre.v-prewritten with an argument or modifiers (v-pre.x), which Vue also reads asv-pre, is now rejected, so Citry and Vue cannot disagree about which content is read as written. No grammar change.third_party/rust/vize_s1_to_s2/src/lower/element.rs, patched copy bumped to0.420.0+citry.7everywhere): insidev-preand on the element that opens it,<slot>,<component>, the built-ins, and any component name stay plain elements, andisis dropped from a plain<component>. Each case matches@vue/compiler-dom3.5.42's output exactly with Citry's options (tests/citry_v_pre_tags.rs).README.citry.mdlists the change.vize_armature, which Citry has not patched. Citry now refuses av-pretemplate the S2 lane declines (V_PRE_NEEDS_S2_LANE), probing S2 with the compile's own options only when the template text containsv-pre. Patchingvize_armatureis Make vize's fallback lane follow Vue's v-pre rules #519 (v1.1).citry_vue_compiler/src/lib.rs) no longer reports a<slot>or<template v-slot>underv-preas an outlet or a fill, so no fill can target one. It readsv-prefrom the opening tag's source, because the vize parser it walks removesv-prefrom the props.v-once/v-memo(_vue/compiler.py): withoutv-prein the template they are refused by spelling, as before. In a template withv-prethey are refused by what they compile to, so av-onceinsidev-prerenders as a plain attribute.v-prewith Citry values (<slot v-pre>{{ x }}</slot>,<component v-pre>, a built-in, or a capitalized component name; SVG's camelCase elements are native): Citry compiles such an element itself as live Vue, so rendering now fails with advice to putv-preon an element around it.Custom elements
An earlier version of this branch let the server renderer write custom element names (tags with
-). The reviewer showed that a custom element defined before hydration, which adds its own children inconnectedCallback, then mismatches on hydration, which the browser-built path avoids. That change is reverted: custom elements, including<keep-alive>insidev-pre, stay built by the browser as before. No Citry UI component or rendered docs example writes a plain custom element.Tests
v-pre, still fails outside it,<c-*>tags keep their checks,v-pre.xandv-pre:xare rejected, slot syntax on a component's child keeps its check); the vize regression test;citry_vue_compilertests for the outlet walk (includingtitle="v-pre",title= v-pre,data-v-pre, and a multi-line opening tag) and for the S2 refusal, both firing and not firing.test_vue_v_pre_plain.py): each tag renders as written;<keep-alive>is built by the browser;v-oncerenders as an attribute; a parent fill is not placed into a<slot>underv-pre; Vue-typed tags carryingv-prewith Citry values are refused, and an SVG<foreignObject v-pre>renders.render_body_snapshots.jsonchanges only hashes, from the version bump.Checks: the parser and Vue compiler crate tests, the vize regression test,
cargo fmtandclippy; the citry and Citry UI suites (13,696 passed); the related browser tests; mypy (also--platform linux); ruff;scripts/validate.py. The Vue render parity check over the whole non-browser corpus: 0 mismatches, 0 Vue errors. One Citry UI type-check test fails in my local environment only (itstyis 0.0.90 where main now needs 0.0.91). An independent reviewer ran three rounds against Vue 3.5.42's compiler and a browser.Not covered
@...attributes insidev-pre(such as@click) still make the server leave that element for the browser to build, which cannot set an attribute named@click. That is unchanged by this PR.is="vue:..."andv-slotinsidev-pre; a custom element carryingv-prewith Citry values, which still compiles as a component.Docs and changelogs
vue/limits.mdandvue/props-and-events.mdnow say the built-ins andv-once/v-memofail outsidev-pre.CHANGELOG.md; two lines inpackages/py/citry_core/CHANGELOG.md.Fixes #515.
🤖 Generated with Claude Code