Skip to content

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

Closed

Description

@JuroOravec

What happens

A component that starts Vue (it has js) and puts a <c-raw> block directly
inside <c-i18n> fails when the page is serialized:

ValueError: prepared opaque HTML values do not match definition declarations

The page never renders. The render cache is not involved: the first render
fails with the cache off. c-client="True" is not needed either, and a
server-only <c-i18n> fails the same way.

Reproduction

from citry import Citry, Component

app = Citry(
    autodiscover=False,
    extensions_defaults={
        "i18n": {"source_locale": "en-US", "locales": ("en-US",)},
    },
)


class Page(Component):
    citry = app
    template = """
        <c-i18n tag="main">
          <c-raw><i>raw body</i></c-raw>
        </c-i18n>
    """
    js = """
        $component({});
    """


str(Page())  # ValueError

Cases that render fine, for comparison:

  • the same template without js, so Vue does not start;
  • <main><c-raw>...</c-raw></main>, where the parent is a plain element and not <c-i18n>;
  • <c-raw> passed as the default slot of an ordinary component (<c-Box><c-raw>...</c-raw></c-Box>
    where Box renders <section><c-slot /></section>).

Where it fails

packages/py/citry/citry/_vue/protocol.py, prepared_manifest(), line 142:

if opaque.keys() != declared_keys:
    raise ValueError("prepared opaque HTML values do not match definition declarations")

Call path: serialize.py:_serialize_render_result ->
_vue/serialization.py:prepare_vue_serialization -> _prepare_initial_result ->
_vue/events.py:_prepare_from_render_result -> _prepare_holding_assets ->
_vue/protocol.py:prepared_manifest.

The opaqueHtml keys in the occurrence's prepared data do not match the opaque HTML sites that
the compiled definition declares. The likely cause is that <c-i18n> renders its body through
I18nProvider (ext/i18n/components.py, a <c-component c-is="host" ...><c-slot /></c-component>
template). The <c-raw> site is then recorded on one definition while its value lands in another
occurrence's prepared data. That cause is not yet confirmed.

Versions

Reproduced on b80bd9249. On 1b64f7102 (current main), the Python changes since b80bd9249
touch only _vue/compiler.py, events.js and runtime.js, and do not touch this path. That commit
was not run, because it needs a rebuilt citry_core.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions