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 start by examining the relevant source files and understanding how v-show is handled in the SSR codegen.
- Assistant
Let me inspect the problematic functions in
plain.rs. - Assistant
Now let me inspect the correct merge path in
collect_element_directive_attr. - Assistant
I need to see how element attributes and v-show are processed together on the non-root path.
- Assistant
Let me look at process_element_attrs and how v-show is called.
- Assistant
Now let me look at process_directive_on_element.
- Assistant
Let me check existing SSR tests and how Vue handles this.
- Assistant
rg is not available, let me use grep.
- Assistant
Let me examine the snapshot tests and the existing v-show unit test.
- Assistant
Let me look at the existing snapshots for v-show.
- Assistant
Let me check how
get_compiled_stringworks and what Vue emits for this case. - Assistant
Let me also look for Vue's ssrTransformShow reference, and how helpers used for style rendering look.
- Assistant
Let me look at Vue's compiler-ssr for how they handle v-show. Maybe there's a submodule or something.
- Assistant
Let me review how the DOM compiler and components handle style merging for v-show.
- Assistant
Let me check how
normalize_prop_entriesmerges multiple style entries. - Assistant
Let me open props.rs
- Assistant
Let me see the rest of process_v_bind_on_element and helpers/constants availability.
- Assistant
Let me check imports and String types used in plain.rs.
- Assistant
Let me check the String usage and how merge_prop_values builds arrays when we need to assemble the style expression.
- Assistant
I have a clear fix plan. Implementing the style merge in
process_v_show_on_elementand skipping duplicate style emission. - Assistant
The edit landed in the wrong file — I'll restore
props.rsand apply the change toplain.rsinstead. - Assistant
Now applying the fix to the correct file.
- Assistant
Now I'll update
process_v_show_on_elementto merge styles. - Assistant
Let me open the process_v_show_on_element function and replace it.
- Assistant
Now I'll replace process_v_show_on_element with a better implementation.
- Assistant
Let me verify this compiles and reproduce the original bug cases.
- Assistant
All existing tests pass. Next I'll run a temporary script to verify the reproduction cases are fixed.
- Assistant
I'll add a temporary debug test in the ssr crate instead.
- Assistant
The fix works across all cases. Cleaning up the temporary test and verifying the final diff.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.