Skip to content

fix: keep a fill's values in its author when a transparent component passes it on - #341

Merged
JuroOravec merged 3 commits into
mainfrom
fix/raw-inside-i18n
Oct 24, 2026
Merged

JuroOravec merged 3 commits into
mainfrom
fix/raw-inside-i18n

Conversation

@JuroOravec

@JuroOravec JuroOravec commented Oct 24, 2026 •

Copy link
Copy Markdown
Member

Fixes #334

What changes

In a component that uses Vue, a <c-raw> block, a Markup value, or #c-ignore contents could fail to render with "prepared opaque HTML values do not match definition declarations". This happened when the content sat inside <c-i18n>, inside <c-provide>, or inside another transparent component (one with no Vue definition of its own) whose content ends up in a component's slot.

Cause (in packages/py/citry/citry/_vue/direct_capture.py):

  • A transparent component has no Vue definition of its own. Assembly therefore writes its template straight into the definition of the component it sits in, and copies the values of that body into that occurrence's prepared data.
  • That copy also ran for a fill inside it that is handed on as a Vue slot. Such a fill is compiled in its author's definition and reads its values from its author's data.
  • <c-i18n> is one such case. It passes its body through a transparent <c-component> to a host component, which wraps the body in a transparent <c-element>.
  • So the <c-raw> HTML also landed in the host's data. The host's definition declares no opaque HTML site, and the manifest check (_vue/protocol.py prepared_manifest) rejected it.

Fix: assembly copies a body's values into an occurrence's data only when the body is compiled into that occurrence's definition.

  • This always holds for the occurrence's own template, so the two root calls pass compiled_here=True.
  • For a fill's body, it holds only when the body stays in the definition: either the fill is written straight into it, or its receiver and author are the occurrence being assembled.
  • The flag that says this was named projected_data. It is renamed compiled_here and documented at the parameter.

Tests

  • New: tests/test_vue_prepared_capture.py::test_raw_html_inside_a_transparent_component_stays_in_its_author. It checks that the HTML lands only in the page's data and that the page's definition reads it. It covers seven shapes:

    • <c-i18n>, server and client;
    • a transparent component inside <c-i18n>;
    • <c-provide> inside <c-i18n>;
    • a transparent component that forwards into an ordinary component;
    • a Markup value inside a transparent component;
    • #c-ignore contents inside a transparent component.

    The shapes fail on main and pass now.

  • Changed: tests/test_vue_direct_relationships.py. The old test test_flattened_projection_namespaces_lexical_text_after_physical_key asserted that a fill's text was copied into the receiving component's data. That component's template never reads it; the author's does. The test is now test_a_fill_passed_through_a_transparent_component_keeps_its_text_in_its_author and checks that the text stays in its author.

  • Changed: citry_ui/quality/tests/test_routes.py. test_flattened_state_projection_binds_lexical_text_but_not_the_indicator_glyph asserted that the accordion and disclosure scenarios' title was copied into each item's data. The scenario page writes the title and passes it into the item's slot, so the page's template reads it from the page's data, and the item's copy was never read. This PR stops writing that copy. The test is now test_projected_title_is_text_in_its_author_and_the_indicator_glyph_is_not; it checks the title in the page's data and still checks that the chevron glyph never reaches Vue as text. (Commit d5a07cd from the Vue lane, cherry-picked; the file passes on this branch, 169 tests.)

The reviewer also ran a 49-shape probe, each shape with and without page js, comparing this branch with main:

  • 43 runs that failed now render.
  • Every run that rendered before still renders the same visible HTML.
  • No definition reads a $citryPrepared key that its data lacks.

Evidence

Run locally on origin/main 1b64f71, with a citry_core built from it:

  • pytest for the citry and citry_ui suites (-m "not e2e"): 9,481 passed.
  • The Vue render parity check (the collect plugin over the whole suite, then check.py --reuse): 0 mismatches, 0 Vue errors.
  • uv lock --check, ruff check, ruff format --check.
  • mypy, including --platform linux.
  • citry-client, protocol contracts, protocol Python copies, events protocol JavaScript.
  • validators.

PR CI runs the cargo phases. This change has no Rust.

Review

An independent adversarial review ran twice, each time with a prose pass. Its findings are folded in:

  • the first version fixed only the direct <c-i18n> case;
  • the flag's name no longer said what it means;
  • test coverage for Markup and #c-ignore;
  • wording.

🤖 Generated with Claude Code

…passes it on

A component that starts Vue and puts a <c-raw> block, a Markup value or
#c-ignore contents inside <c-i18n>, <c-provide>, or another transparent
component that passes it into a component's slot failed to render with
"prepared opaque HTML values do not match definition declarations".

A transparent component has no Vue definition of its own, so assembly
writes its template straight into the definition of the component it
sits in, and copies the values of that body into that occurrence's
prepared data. That
copy also ran for a fill inside it that is handed on as a Vue slot,
although such a fill is compiled in its author's definition and reads
its values from its author's data. <c-i18n> is one such case: it passes
its body through a transparent <c-component> to a host component, which
wraps it in a transparent <c-element>. The <c-raw> HTML then also landed
in the host's data, whose definition declares no opaque HTML site, and
the manifest check rejected it.

Assembly now copies a body's values into an occurrence's data only when
the body is compiled into that occurrence's definition: always for the
occurrence's own template, and for a fill's body only when the body
stays there (the fill is written straight into the definition, or its
receiver and author are the occurrence being assembled). The flag that
says so is renamed compiled_here. The code works out which occurrence
receives the body before it transforms the body.

Tests: the <c-raw> HTML stays only in the page's data, and the page's
definition reads it, for <c-i18n> (server and client), a transparent
component inside <c-i18n>, <c-provide> inside <c-i18n>, a transparent
component that forwards into an ordinary component, and a Markup value
and #c-ignore contents inside a transparent component. The test that locked the extra copy of a
fill's text into the receiving component's data now checks that the
text stays in its author.

Fixes #334

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@JuroOravec

Copy link
Copy Markdown
Member Author

While fixing #329 I hit the same error ("prepared opaque HTML values do not match definition declarations") from two shapes, and wrote a separate fix before I saw this PR. Both shapes render on this branch (3acbb64) and fail on main, so I dropped my branch. If you want them as test cases:

  1. The receiving component's <c-slot /> sits inside <c-element>, and the fill holds a Markup value, <c-raw> or #c-ignore:

    <!-- Frame (has js) -->
    <c-element c-is="'section'"><c-slot /></c-element>
    <!-- Page (has js) -->
    <main><c-Frame>{{ html }}<c-raw><i>raw</i></c-raw><div #c-ignore><s>kept</s></div></c-Frame></main>
    

    On this branch the page hydrates with no declines, and the host is
    <main><section><!--[--><!--[--><b>trusted</b><!--]--><!--[--><i>raw</i><!--]--><div><!--[--><s>kept</s><!--]--></div><!--]--></section></main>.

  2. A transparent component inside a fill that goes to an ordinary component:

    <!-- Frame (has js) -->
    <section><c-slot /></section>
    <!-- Wrap (transparent = True) -->
    <div class="wrap"><c-slot /></div>
    <!-- Page (has js) -->
    <main><c-Frame><c-Wrap>{{ html }}</c-Wrap></c-Frame></main>
    

    Host on this branch:
    <main><section><!--[--><div class="wrap"><!--[--><b>trusted</b><!--]--></div><!--]--></section></main>.

A reviewer of my version found two older bugs nearby. Neither this PR nor my version fixes them, and both fail the same way on main:

  • A <c-fill name="body" fallback="fallback"> whose body shows {{ fallback }} shows the caller's value instead of the receiver's (caller:<i>caller</i> where receiver belongs). With Markup values it fails with "opaque HTML site is invalid". The receiver's fallback is compiled in the caller's template, but its values stay in the receiver's data.
  • A fill body that a sibling component copies in (a Slot captured in one component and shown by a transparent component elsewhere) can show the wrong text. The copied value and the page's own text end up with the same key in the page's data.

I can open issues for these two if that helps.

🤖 Generated with Claude Code

JuroOravec and others added 2 commits October 24, 2026 22:17
The accordion and disclosure scenario test asserted that the scenario's
"outline" title was copied into each item's prepared data. The title is
written by the scenario page and passed into the item's slot, so the
page's template compiles it and reads it from the page's data; the item's
copy was never read. Since #341, assembly no longer writes that copy, so
the test now checks the title in the page's data and still checks that
the chevron glyph never reaches Vue as text.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@JuroOravec
JuroOravec merged commit 7ed5f5d into main Oct 24, 2026
3 of 7 checks passed
@JuroOravec
JuroOravec deleted the fix/raw-inside-i18n branch October 24, 2026 21:23
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.

<c-raw> directly inside <c-i18n> fails to serialize in a Vue component

1 participant