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).ADDITIONAL ADVICE
- Assistant
I’ll inspect the SSR code and nearby tests first, then trace how style attributes and v-show are represented so the fix matches existing codegen conventions. I’ll reproduce the problematic output if practical, implement the smallest general merge change, run targeted tests, and review the diff before submitting.
- Assistant
The existing single-root path already models v-show as a
styleprop entry, while the element path bypasses prop collection and appends raw markup. I’m now locating the element property emission flow and all call sites to determine how to merge static and bound styles without changing unrelated attributes or root behavior. - Assistant
The non-inherit path has a useful complication:
:stylealready merges a static style into_ssrRenderStyle([static, bound]), but v-show is emitted independently afterward. I’ll make v-show own the single style emission only when present, suppressing the original static style and style bind emissions in that case, and render an array containing static style, bound style, and the conditional{ display: "none" }value. This preserves existing behavior when v-show is absent and avoids duplicate attributes regardless of directive order. - Assistant
The implementation is in place and formatted. I noticed an edge case worth correcting before testing: a malformed
v-showwithout an expression currently returns early, so it must not cause an existing style attribute to be suppressed. I’ll make the detection require an expression, then run the SSR snapshot tests and inspect generated output for static-only and bound-style cases. - Assistant
The targeted tests compile and confirm the fix changes non-root v-show output to one
_ssrRenderStyle(...)attribute; the two existing snapshots fail only because they assert the old, buggy output, and I will not modify repository tests or snapshots. Component v-show tests still pass. I’ll remove transient.snap.newfiles, run formatting/checks, and verify the final diff has no unintended changes. - Assistant
Verification is complete:
cargo check -p vize_atelier_ssrpasses, formatting andgit diff --checkpass, and the only modified file is the intended codegen file. The targeted snapshot run confirms component cases remain passing; the two old non-root snapshots fail solely because they encode the defect’s duplicate/raw-style output, and transient snapshot files were removed. Edge cases covered include static style, bound style, both together, directive ordering, no existing style, and malformed v-show (which no longer suppresses style).Checklist:
- Reproduced/confirmed the reported behavior: yes, the targeted snapshots showed the old standalone conditional attribute.
- Confirmed the fix resolves it: yes, generated output now has one
_ssrRenderStylestyle attribute. - Considered edge cases: yes, including static/bound combinations and missing v-show expressions.
- Ran affected tests: yes; compilation/checks pass, component tests pass, and stale snapshots fail only due to intentional output correction; tests/snapshots were not modified.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.