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
<template> <div class="wrapper"> <span style="color:red" v-show="ok">x</span> </div> </template>Actual
<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 staticstyleattr or:stylebinding and merge(expr ? null : { display: 'none' })into a single style binding, reusing the merge logic already present in the single-root path (collect_element_directive_attr, plain.rs:245-254).ADDITIONAL ADVICE
- Assistant
I’ll inspect the SSR code and nearby tests first, then trace how style attributes and v-show are represented. I’ll implement the smallest general merge consistent with the existing single-root path, run targeted tests or a temporary reproduction, review the diff, and submit only after verification.
- Assistant
The bug is confined to the direct attribute path: static styles are emitted literally, dynamic styles are emitted by
v-bind, and v-show independently appends another attribute. I’ll make that path suppress existing style emissions only when v-show is present, then have v-show emit one_ssrRenderStylecall over the existing static style, dynamic binding, and conditional display object. Elements without an existing style will retain their current output, minimizing snapshot churn. - Assistant
The code now compiles and all 68 existing SSR snapshot tests pass. I also checked the diff: the ordinary style bind is skipped only for v-show elements, while the existing no-style v-show snapshot remains unchanged. I’ll run a temporary executable-style reproduction for both static and bound styles (then remove it), since the existing suite does not contain these exact cases.
- Assistant
Verification is complete: the temporary reproduction generated exactly one
styleattribute for both static and:stylecases, and both included the conditionaldisplay: noneobject. The fullvize_atelier_ssrtest suite (68 tests plus doc tests) passes, formatting andgit diff --checkpass, and the temporary example was removed. The missing-expression edge case is also preserved by only treating an actual v-show expression as mergeable. I’ll submit the single source-file change now.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.