ISSUE DESCRIPTION fix(atelierssr): v-show on a non-root element with an existing style…
- User
ISSUE DESCRIPTION
fix(atelier_ssr): v-show on a non-root element with an existing style attr/:style binding emits a duplicate style attribute, breaking display:none hiding
Location
crates/vize_atelier_ssr/src/codegen/element/plain.rs:490(process_v_show_on_elementunconditionally appends a standalonestyle="display: none;"chunk; its element param is unused)crates/vize_atelier_ssr/src/codegen/element/plain.rs:245-254(collect_element_directive_attr— the single-root/inherit_attrs path that correctly merges into one style binding via_mergeProps; reference for the fix)
Problem
process_v_show_on_element(used on every non-fallthrough-root element) emits a standalonestyle="display: none;"chunk instead of merging v-show into the element's existing style. When the element already has a staticstyleattribute or a:stylebinding, the generated HTML contains TWOstyleattributes. The HTML parser keeps the FIRST, sodisplay:noneis dropped and v-show fails to hide the element (or, in the:stylecase, thedisplay:nonechunk renders first and the bound style is silently dropped). The sibling single-root path already merges correctly via_mergeProps, proving the element-level path is the buggy one.Reproduction
vue<template> <div class="wrapper"> <span style="color:red" v-show="ok">x</span> </div> </template>Actual
js<span style="color:red"${((_ctx.ok) ? "" : " style=\"display: none;\"")}> // when ok===false -> <span style="color:red" style="display: none;">x</span> ; browser keeps the first, display:none ignored<span v-show="ok" :style="{ color }">likewise emits two style attributes.Expected
Vue's SSR
ssrTransformShowrewrites v-show into the single style binding (style=[existing, expr ? null : {display:'none'}]) so there is exactly onestyleattribute.Suggested direction
In
process_v_show_on_element(plain.rs:479-493), inspect the element for an existing static attr or binding and merge into a single style binding, reusing the merge logic already present in the single-root path (, plain.rs:245-254). - Assistant
I’ll inspect the SSR element code, its surrounding merge logic, and relevant tests/snapshots first. Then I’ll reproduce the generated output, implement the merge at the appropriate transform stage, and run focused plus broader tests.
- Assistant
The direct path serializes each prop independently and therefore cannot fix this merely by changing the final
v-showchunk: existing static and bound styles must be suppressed or folded when they are processed. I’m tracing prop iteration and root/fallthrough selection now, and locating the crate’s test harness without relying on unavailablerg. - Assistant
A robust direct-path design is to let
v-showown style emission whenever present: skip the ordinary static/:styleserializers, then haveprocess_v_show_on_element(el, dir)emit one_ssrRenderStylebinding containing static style, bound style, and the conditional display object. This preserves declaration order and mirrors the existing collected-props semantics. I’ll confirm exact expected compiler shape and inspect helper/utilities before editing. - Assistant
The existing direct serializer already special-cases one static plus one static-argument
:style; I’ll extend that same supported model forv-show. The conditional style will always go through_ssrRenderStyle, while style-lessv-showcan retain its current compact conditional attribute output to minimize unrelated snapshot churn. Static style and:stylewill be skipped only when a validv-showexpression exists, preventing accidental attribute loss for malformed directives. - Assistant
I’ll now modify only production code. The implementation will collect all explicit static and static-argument bound style values (rather than only the first), append the
v-showconditional object, and serialize them through one_ssrRenderStyle(...)attribute. Existing style output is suppressed in the direct path only whenv-showhas an expression. - Assistant
The scripted replacement intentionally aborted before writing because the exact function text differed in escaping from the script; no source change occurred. I’ll apply a line-oriented patch instead and then format/check the diff.
- Assistant
The diff now implements a single style attribute for both static and bound styles. To reproduce and verify without adding repository tests, I’ll create a temporary external Cargo program under
/tmpthat calls the public SSR compiler on the reported static-style case and its:stylecounterpart, then inspect generated code and count style attribute emission sites. - Assistant
The external reproduction confirms all three relevant combinations generate exactly one literal
style="..."attribute and merge the hide object after existing styles. I’ll run the full SSR crate test suite next; unchanged basicv-showsnapshots should remain stable because the compact no-existing-style path was retained. - Assistant
All 108 SSR crate tests pass, including snapshots for root merged props, basic
v-show, and ordinary style bindings. I’ll run strict Clippy and then review the final diff/status for unintended files or lint-level issues.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.