fix(atelierssr): v-show on a non-root element with an existing style attr/:style binding…
- User
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 staticstyleattr 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 v-show codegen paths and how the single-root merge works, then align
process_v_show_on_elementwith that logic. - Assistant
Checking how Vue emits this and whether similar patterns exist elsewhere:
- Assistant
Implementing the fix: consolidating style emission into
process_v_show_on_elementwhenv-showis present, and skipping duplicate style handling elsewhere. - Assistant
Fixing a mutability issue:
get_dynamic_bind_exprequires&mut self. - Assistant
Output looks correct. Accepting the new snapshots.
- Assistant
Fixed the duplicate
styleattribute bug by consolidating style emission whenv-showis present on a non-root element.Root cause
process_v_show_on_elementalways appended a standalonestyle="display: none;"chunk, while staticstyleand:stylewere emitted separately — producing twostyleattributes where the browser keeps only the first.Fix
In
plain.rs:- Skip static
styleinprocess_element_attrswhen the element hasv-show(same pattern as skipping it when:styleexists). - Skip
:stylebind handling inprocess_v_bind_on_elementwhenv-showis present — style is handled in one place. - Merge in
process_v_show_on_elementwhen static or bound style exists, using_ssrRenderStyle([existing..., (expr ? null : { display: "none" })])— matching the single-root_mergePropspath.
- Skip static
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.