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 inspecting the relevant code around
process_v_show_on_elementand the single-root merge path mentioned in the issue. - Assistant
Next I'll read the correct merge path in
collect_element_directive_attrand how style attributes are generated today. - Assistant
Let me read the full relevant sections of the file.
- Assistant
Let me continue reading the collect_element_directive_attr and related style/v-show handling.
- Assistant
Let me see the process_directive_on_element and how style binding is processed non-inherit path.
- Assistant
I'll search for existing SSR v-show tests and how Vue handles this merge.
- Assistant
rg is not available, let me use grep.
- Assistant
Let me look at the existing SSR tests for v-show and how component merges style.
- Assistant
Let me look at how normalize_prop_entries merges style, and how components handle v-show with style. Also look at snapshots for current v-show behavior.
- Assistant
Let me look at the snapshots and how Vue's SSR handles this. Also look at component v-show merge for reference.
- Assistant
I'll check how the SSR test harness compiles templates and when inherit_attrs is applied.
- Assistant
I'll check recent related commits and whether Vue's
ssrTransformShowis referenced in the tree. - Assistant
Let me look at how components handle v-show merge, since that's a correct reference.
- Assistant
I'll inspect
has_v_show/get_v_show_expand check how helpers like_ssrRenderStylebehave with arrays. - Assistant
I have a clear plan. Implementing the merge of v-show into a single style emission next.
- Assistant
Let me find the module structure.
- Assistant
Hmm grep returned nothing useful. Let me read element.rs
- Assistant
I'll implement the merge logic in
plain.rs, mirroring the class/style merge pattern. - Assistant
Let me implement the changes. I'll need a helper to build the v-show style expression and to get the show exp as string.
- Assistant
Now I'll update the style binding path and
process_v_show_on_element. - Assistant
The previous edit corrupted the class binding section — I'll restore it.
- Assistant
I need to fix the broken class match arm and the boolean attr arm completely.
- Assistant
There's an extra
}at line 421. Let me fix that and update process_v_show_on_element. - Assistant
Now I'll update
process_v_show_on_elementand add thev_show_style_exprhelper. - Assistant
Verifying exports and checking whether the crate compiles.
- Assistant
Good, the exports are available. Let me also check how cstr works with String arguments - does it need references?
- Assistant
Let me read the cstr macro
- Assistant
I'll compile the crate and run the SSR snapshot tests.
- Assistant
All existing tests passed. I'll write a temporary script to verify the reproduction cases.
- Assistant
I'll add a temporary verification test, run it, then remove it.
- Assistant
Cleaning up the temp test and verifying the single-root inherit_attrs path still works.
- Assistant
Both paths are good. Cleaning up and running the full package tests.
- Assistant
Confirming full unit-test results from the package:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.