Repository navigation
Description
What happens
In a component that uses Vue, an element inside v-pre that keeps Vue syntax as written, such as :x="y", is not written by the server. Its parent becomes a shell, an element marked data-allow-mismatch="children", and Vue builds the parent's children in the browser:
<main><table v-pre><tr><td><b :x='y' title='t'>A</b></td></tr></table></main>
The server HTML, on main at cada47d9f:
<td data-allow-mismatch="children"><b title="t">A</b></td>hydration_admission records ('unsupported-attribute', ':x', 'shell', 'td'). A <div v-pre> behaves the same way. Once Vue runs, the page is right: Vue builds <b :x="y" title="t">A</b> in the browser. Only the first paint lacks the attribute, and the shell's contents are rebuilt instead of hydrated.
Why: this is deliberate
- Hydration does not set plain attributes. It applies only listeners,
.propkeys, a few value keys and the keys the render marks as dynamic (hydrateElementin runtime-core). It trusts the server HTML for every other attribute.- So if the server wrote the element without
:xand let Vue hydrate it, the attribute would stay missing for good. - Declining is what keeps the page right.
- So if the server wrote the element without
- The hydration writer declines the name.
client_attribute(crates/citry_vue_compiler/src/server_render.rs) writes only names that start with a lowercase ASCII letter and continue with lowercase letters, digits,-,_or:. Any other name takes "paths the server does not model", so the part is declined. - The shell writer leaves it out. The writer for a shell's contents (
StaticWriter) leaves out any name for whichis_static_attribute_nameis false, which needs a leading ASCII letter. So the shell shows<b title="t">without:x.
Possible improvement
A name that starts with : could be written in both writers:
- the HTML tokenizer reads
:x="y"as the attribute:xexactly as written; - Vue's client sets it with
setAttribute(":x", "y"), because:has no meaning inpatchPropand":x" in elis false.
That would let a v-pre element with bound-looking attributes render fully on the server and hydrate. Names starting with @ or # should stay declined: they are not valid XML names, and the browser's setAttribute refuses them.
Before changing it, check:
- Render code: what Vize's render code holds for each of these names under
v-pre. - Hydration: that it adopts the element without a mismatch warning in Vue's dev build.
- Static parts: that a
v-preelement Vue compiles to a static string (createStaticVNode) is unaffected.
Priority
Low. Only first-paint markup inside v-pre is affected, and the final page is correct.
Activity