Skip to content

fix(vue): accept on an event what the page accepts for static HTML, and name each refusal - #807

Merged
JuroOravec merged 2 commits into
mainfrom
fix/c3-gaps
Nov 19, 2026
Merged

JuroOravec merged 2 commits into
mainfrom
fix/c3-gaps

Conversation

@JuroOravec

Copy link
Copy Markdown
Member

(Opus 5.5)

Fixes four gaps in the static HTML feature from #803, which citry-django's step 6 found. citry 1.1.0 is waiting on this PR.

Changes

  1. A server event crashed on one template shape. In a template with foreign spans, each {{ }} writes a Markup part. The page accepted it, but an Events Render refused it with "unsupported raw output: Markup". Now the Vue writer decides which parts it accepts with one function, is_prepared_leaf_part. The event's pre-check (_validate_prepared_render) calls that function, and so does _static_part_html when it joins a static block, so the two paths accept the same parts. The writer's checks on the block (fragment, <noscript>, svg and text-only parents) still run on both paths, and a test shows an event refuses the same Markup value the page refuses. Joining a static block now takes only a plain str or Markup, so a str subclass is refused there as everywhere else.

  2. Named Experimental exceptions. A refusal now raises a subclass of StaticHtmlError, and each subclass also subclasses the built-in type Citry raised before:

    • IncompleteStaticHtmlError(ValueError)
    • VueInsideStaticHtmlError(ValueError), with .component_name
    • ScriptInStaticHtmlError(ValueError), with .tag
    • VueSyntaxInStaticHtmlError(TypeError), with .component_name and .syntax
    • StaticHtmlPlacementError(TypeError), which also covers the Markup and <c-raw> placement refusals.

    They are exported from citry and listed as Experimental in versioning.md and in reference.yml.

  3. Clearer "inside an element" message. Sometimes a render that is not a component wraps the component, such as a Django {% if %} block or a <c-for> loop. The message used to say "A part that needs Vue" in that case. Now it names the component and says to move it out of the element, or to write the element and the tags around it in Citry syntax.

  4. @click was not checked in some templates. The refusal used to read only the template of the component that owned the static block. Now _refuse_vue_in_static_templates walks the whole tree before assembly and reads the template that each render ran (CitryContext.template_record). That adds three cases that were not checked before: the template passed to render_template(), fills written in it, and transparent components (found with Mechanism 3). The message says an Alpine.js short form such as @click is refused too, and that its long form, x-on:click, works.

Tests

  • New and updated tests are in test_vue_static_foreign_html.py and test_vue_prepared_capture.py. Eight of the new tests fail on the base, through a shim that maps the new names to the built-in types, and pass here. The str subclass test was added during review, from the reviewer's probe on the base.
  • citry suite (no e2e): 15,175 passed. Two failures (tzdata and pydantic versions) and nine collection errors (script modules that are not installed) come from my local environment and also happen on the base.
  • mypy is clean on macOS and with --platform linux. ruff check and ruff format pass.
  • citry-django (vue-islands) run against this branch: 447 passed, with 2 expected failures. Its strict xfail for gap 1 now passes (XPASS(strict)). Its gap 3 test expected the old generic message and now gets "Tick needs Vue, ...", because Citry now names the component. citry-django was not edited.

Benchmark

Base and head ran alternately, each sample in a fresh process.

Page Change (min) Change (median)
Interactive page with 300 child components (Vue writer path) +0.9% +0.5%
benchmarks/slot_renders.py --scenario filled, 9 runs -0.6% +0.1%

Security (Mechanism 7)

An independent reviewer compared every route that a Markup or plain-string part can take on the page and on an event: a static run, a Markup part on its own, a slot fill, svg and text-only parents, #c-ignore and v-pre contents, <c-raw>, simple='vue' rows, and cached renders. Every route is safe; it found no hole. The template walk for gap 4 has no bypass through the payload cache, call runs, projections, nested templates or on_render results. Output of a template with foreign spans is never stored in the render cache.

Versioning

C3 (#803) is unreleased and ships in 1.1.0, so the new refusals do not break anything users have. The new classes subclass the old built-in types, so existing except ValueError and except TypeError clauses keep working. One line under ### Fixes covers a change to 1.0.x behaviour: an Events Render no longer fails when a Markup value, such as slot content passed from Python, reaches it. All of this fits the 1.1.0 minor release.

🤖 Generated with Claude Code

https://claude.ai/code/session_01KUhrHaXagmW5ZxpRAMwyom

JuroOravec and others added 2 commits November 19, 2026 20:04
…nd name each refusal

An Events Render now checks its tree with the Vue writer's own
is_prepared_leaf_part, the function the writer uses to decide which
parts it accepts. So the Markup part that each {{ }} of a template with
foreign spans writes renders on an event as it does on the page, and
the writer's checks on the block still apply on both paths.

Each refusal of HTML that Vue would insert as a static block now raises
a named, Experimental subclass of StaticHtmlError that also subclasses
the ValueError or TypeError raised before: IncompleteStaticHtmlError,
VueInsideStaticHtmlError, ScriptInStaticHtmlError,
VueSyntaxInStaticHtmlError and StaticHtmlPlacementError.

When a block such as Django's {% if %} or a <c-for> loop wraps an
interactive component inside an element of such HTML, the refusal now
names the component and says to move it out of the element.

Vue syntax in a template with foreign spans is now refused for every
template whose output reaches a Vue app, read from the template each
render ran: this adds the template passed to render_template(), fills
written in it, and transparent components, which were skipped silently.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01KUhrHaXagmW5ZxpRAMwyom
- A static block now joins only a plain string or Markup, the same parts
  is_prepared_leaf_part accepts, so a str subclass after a plain string
  is refused on the page as it is on an event.
- The Markup and <c-raw> placement refusals raise
  StaticHtmlPlacementError too.
- The Vue syntax refusal says the attribute would stay a plain attribute
  that Vue never compiles, and that an Alpine.js short form such as
  @click is refused too, while its long form x-on:click is not.
- Changelog: an Events Render with a Markup value, such as slot content
  from Python, no longer fails (a fix to 1.0.x behaviour).
- One lru_cache on the template scan, and accurate comments and docs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01KUhrHaXagmW5ZxpRAMwyom
@JuroOravec
JuroOravec merged commit 09cfdba into main Nov 19, 2026
23 of 34 checks passed
@JuroOravec
JuroOravec deleted the fix/c3-gaps branch November 19, 2026 19:24
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.

1 participant