Skip to content

fix(vue): let citry preview render components with Events - #626

Merged
JuroOravec merged 2 commits into
mainfrom
fix/580-preview-events
Nov 14, 2026
Merged

JuroOravec merged 2 commits into
mainfrom
fix/580-preview-events

Conversation

@JuroOravec

@JuroOravec JuroOravec commented Nov 13, 2026 •

Copy link
Copy Markdown
Member

Fixes #580.

What was wrong

citry preview failed for any component that uses Events. The preview page passes its page template into a small {{ page }} root template. When Events are on, Citry compiles the page into Vue templates, and a nested template render that is not a component's own output is compiled into the enclosing component's Vue template. Citry checks for a whole-page template so that only the <body> contents reach the Vue compiler, but that check only read the parts at the top level of each Vue template. The nested page's <!doctype> and <head> therefore reached the compiler, which rejected them.

The fix

_logical_typed_body in citry/_vue/direct_capture.py now looks inside a lone nested render when the top level holds no page shell, skipping whitespace around it. If the nested render holds a shell, the function returns a copy of that render with the same render frame (render id and owner), holding only the body contents. The server still writes the doctype and head from the full render, as it already did for nested renders.

Cases that still fail as before, with the same Vue compile error: content beside {{ page }} (such as a comment), and a whole page passed as a component's slot fill.

Checks

  • New tests: a nested {{ page }} root with a whole-page template (one-line wrapper, multi-line wrapper, wrapper component), and a preview of a component with Events served through the preview route. They fail without the fix.
  • Focused suites: preview, Vue, Events, extension, and debug tests (3623 passed).
  • ruff check and format; mypy on packages/py/citry/citry, also with --platform linux.
  • Headless Chromium against PreviewServer: the preview renders, the app mounts once, two clicks run the Events handler and update the count to 2, and the console shows no errors.
  • An independent review covered correctness, a sweep for other one-level page-shell checks (none affected), and a security pass on how the nested page's head and body reach the browser (no issue found; the nested output matches the top-level page output byte for byte after normalizing ids).

🤖 Generated with Claude Code

JuroOravec and others added 2 commits November 14, 2026 14:36
…root

`citry preview` wraps its page template in a `{{ page }}` root. A nested
template render that is not a component's own output joins the
enclosing occurrence's Vue template, and the document-shell check only
read that occurrence's top-level parts, so the doctype and head reached
the Vue compiler and failed it for any component with Events.

The check now looks through a lone nested non-component render and
narrows a copy of it, keeping its frame, to the body contents.

Fixes #580.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The whitespace a multi-line wrapper template writes around `{{ page }}`
arrives as a run of static markup, which stopped the walk down to the
page. Skip whitespace-only static runs too, cover a multi-line wrapper
and a wrapper component in the test, and tighten the docstring and
changelog wording.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@JuroOravec
JuroOravec force-pushed the fix/580-preview-events branch from d41060b to 66833cf Compare November 14, 2026 13:39
@JuroOravec
JuroOravec marked this pull request as ready for review November 14, 2026 13:39
@JuroOravec
JuroOravec merged commit db4d13f into main Nov 14, 2026
11 of 17 checks passed
@JuroOravec
JuroOravec deleted the fix/580-preview-events branch November 14, 2026 14:01
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.

citry preview fails for a component with Events (Vue compile error at <!doctype>)

1 participant