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).Interface
- Assistant
I'll start by examining the relevant code in
plain.rsaroundprocess_v_show_on_elementand the reference merge path. - Assistant
Next I'll inspect the single-root merge path and how element attributes are collected for style.
- Assistant
I need to see how elements process attrs overall and where
process_v_show_on_elementis invoked. - Assistant
Let me read the whole file from the beginning to understand the flow better.
- Assistant
Let me continue reading the process_element_attrs function.
- Assistant
Now let me look at process_directive_on_element and specifically how style binding is handled.
- Assistant
Let me read the rest of the style binding code.
- Assistant
I'll check for existing v-show SSR transforms and related tests in the codebase.
- Assistant
Let me search for SSR tests related to v-show
- Assistant
Let me look at the SSR snapshot tests and existing snapshots for v-show, and also the transforms.rs.
- Assistant
Let me look at Vue's ssrTransformShow to understand the expected output better.
- Assistant
Let me look at the existing v-show snapshots and related code.
- Assistant
I'll inspect how style props are normalized and merged in the props helpers.
- Assistant
Let me look at props.rs for normalize_prop_entries
- Assistant
I have a clear plan: merge v-show into the style path the same way static/dynamic style already merges. Implementing that now.
- Assistant
Let me check the module structure
- Assistant
Looking at plain.rs, it already uses
crate::get_v_html_expetc: - Assistant
Now I'll apply the three coordinated changes in
plain.rs. - Assistant
Next I'll update the
:stylebinding path to fold in v-show. - Assistant
Checking how
expression_to_stringtypes work and whetherto_compact_string/merge_prop_valuesare in scope. - Assistant
Updating
process_v_show_on_elementto merge with existing style instead of emitting a duplicate attribute. - Assistant
Removing the duplicate doc comment left behind by the edit.
- Assistant
Adding the missing blank line, then compiling and running tests.
- Assistant
Checking the test helper and compiling a quick reproduction of the issue.
- Assistant
I'll build the crate and run a temporary example to verify the compiled output.
- Assistant
Existing tests passed. Writing a temporary reproduction to confirm the merge behavior.
- Assistant
I'll run the reproduction from the workspace using the repo toolchain.
- Assistant
Need to mkdir first
- Assistant
Checking attribute order when class comes before style:
- Assistant
Cleaning up the temp example and running the full SSR snapshot suite.
- Assistant
All 68 snapshot tests passed. Running the package unit tests as a final check.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.