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/bindings are represented and how the root path merges them. I’ll implement the smallest consistent fix, run targeted tests (or a focused reproduction if no suitable test exists), review the diff, and only then submit.
- Assistant
The existing root/inherit-attrs collector already emits a
styleprop entry forv-show, while the direct element path appends raw markup afterward. I’m now examining that direct path and the prop/codegen ordering to determine how to merge static and dynamic styles without changing unrelated attribute behavior. - Assistant
The direct path has two relevant cases: static style is currently skipped when a dynamic style bind exists, and the bind handler already renders
[staticStyle, dynamicStyle]. I’ll extend that same rendering to append the v-show value, and make static-onlystylebe skipped when v-show exists so v-show can emit one combined style attribute. If no style exists, the current standalone v-show output remains unchanged. - Assistant
The first scripted edit made no source changes because one exact-text assertion did not match; the test command only rebuilt and confirmed the existing v-show snapshots. I’ll apply the changes in smaller patches against the exact current text, then add a temporary compilation check via the existing test harness rather than modifying repository tests.
- Assistant
The patch exposed a quoting mistake in the generated Rust string for the unchanged fallback v-show expression; compilation correctly caught it before tests ran. I’ll repair that literal using the original escaped form, then reformat and run the focused tests.
- Assistant
The focused tests now compile and pass. The implementation uses one style emission for static style + v-show and augments dynamic
:stylewith the v-show object; plain v-show remains byte-for-byte compatible. I’ll inspect the generated code paths with a temporary standalone test mechanism (outside the repository), run the broader SSR tests, and review for borrow/order edge cases. - Assistant
The full 68-test SSR snapshot suite passes. One edge case remains worth correcting: malformed
v-showwithout an expression should not cause a static style to be skipped, since the directive handler intentionally does nothing in that case. I’ll make the detection require an expression, then rerun formatting and tests, and inspect status. - Assistant
The edge-case adjustment is in place; all 68 SSR snapshot tests pass again, and
git diff --checkreports no whitespace errors. The diff is limited to the plain-element SSR codegen file. I’ll do one final diff review and run the package’s library tests, then submit.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.