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 inspect the SSR element code, nearby merge implementation, and relevant tests to understand the AST and code-generation conventions before reproducing the duplicate attribute.
- Assistant
The direct path serializes each prop independently, so merely changing
v-showis insufficient unless it avoids the existing style serializer or emits the merged style at the correct prop position. I’ll inspect the full element loop and prop structures, then locate snapshot/fixture infrastructure withgrep(ripgrep is unavailable). - Assistant
A robust fix should centralize direct-path style emission: when
v-showand any static or bound style coexist, style serialization must include the hide object and thev-showdirective itself must emit nothing. I’ll check Vue’s exact SSR output and the repository’s helper methods before implementing that behavior without altering tests. - Assistant
The project already exposes
get_v_show_exp, and Vue’s conceptual lowering can be represented naturally by the existing_ssrRenderStyle([...])direct serializer. I’ll inspect current style snapshots and the helper implementation, then patch static and dynamic style branches while preserving the current no-stylev-showoutput to minimize unrelated snapshot churn. - Assistant
I’ll implement the merge in the two existing style serialization points: static style is deferred to
process_v_show_on_element, while bound style appends the hide object to_ssrRenderStyle’s array. This handles directive/attribute order, static-plus-dynamic style, and valueless static style while leaving plainv-showoutput unchanged. - Assistant
The patch now produces one
_ssrRenderStylecall for both reported cases. I’ll compile and run the SSR crate tests; this will also reveal borrow/type issues and confirm unchanged existing snapshots. - Assistant
All 108 SSR tests pass. To verify the actual reported templates rather than infer from code, I’ll create a temporary example executable outside the tracked change set, compile the static and bound-style reproductions, inspect their generated code, and immediately remove it.
- Assistant
The reproduction now emits exactly one style attribute in all three combinations, with the hide object last so
display:nonewins when false. I’ll run Clippy for the affected crate and inspect the final diff for unintended files or style issues.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.