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
Now let's edit
process_element_attrsto handle the static style attribute merge with v-show:Assistant
There's a duplicate closing brace at line 432. Let me remove it.
Assistant
Good, that's fixed now. Now let's update
process_v_show_on_elementto skip when style is already handled, and add theget_v_show_exphelper method.Assistant
Now let's add the
get_v_show_exphelper method:Assistant
Now let's build to check compilation.
Assistant
Compiles cleanly. Now let's write a quick reproduction script to verify the fix produces a single style attribute.
Assistant
There are existing snapshot tests. Let's inspect them.
Assistant
I'll write a quick temp script using this crate's public API to reproduce the issue and verify the fix.
Assistant
All cases now produce exactly one
styleattribute, order-independent, and the no-style case is unchanged. Now let's clean up the example file and run the existing test suite.Assistant
All tests pass. Let's also run the full workspace test suite to check nothing else broke.
Assistant
Whole workspace builds. Let's also run clippy for the file for style guideline (not strictly required but good check), and double-check the class attribute path isn't broken, then review the diff.
Assistant
No clippy warnings. Now let's clean up temp files and run the full test suite once more for confidence.
Assistant
Good, only the intended file is modified. Let's run the full workspace test suite to be thorough.
Assistant
Confirmed pre-existing failure unrelated to my change. My changes are restored (stash popped). Let's re-verify the target crate tests once more and finalize.
Assistant
All good. Now let's go through the checklist explicitly.
Checklist review:
Assistant
-
If an error was reported in the issue description, I have successfully reproduced it. — Yes. I wrote a temporary example binary (later removed) that compiled the exact reproduction templates from the issue (
<span style="color:red" v-show="ok">, and the:stylevariant) with the unmodified code, confirming duplicatestyle="..."andstyle="display: none;"chunks were emitted, matching the issue's "Actual" output. -
If an error was reported in the issue description, I have confirmed that my fix resolves the error. — Yes. After the fix, the same reproduction cases all produced a single merged
style="${_ssrRenderStyle([...])}"attribute using_ssrRenderStyle, mirroring Vue'sssrTransformShowapproach referenced in the issue (single style binding via array merge, analogous to_mergePropsused in the single-root path). I tested both attribute orderings (stylebefore/afterv-show,:stylebefore/afterv-show) since the fix must be order-independent, and confirmed the case with no style at all is unchanged.
-
Assistant
-
I have thought about edge cases and made sure my fix handles them as well. — Considered:
- v-show with no style attribute/binding at all → unchanged standalone behavior (verified via existing snapshot tests
basic_v_show/v_show_with_other_attrs, both still pass). - v-show + static
styleattr, in either source order → merges into one_ssrRenderStyle([...])call, order-independent since I precompute viaget_v_show_exp/get_element_attr_valuescans rather than relying on iteration order. - v-show +
:stylebinding, in either source order → merges into one call. - v-show on component root vs. non-root plain element → the component/single-root path () was already correct and untouched; only the plain-element non-root path was changed.
- v-show with no style attribute/binding at all → unchanged standalone behavior (verified via existing snapshot tests
-
Assistant
The diff looks clean and correctly addresses the issue. Now let's submit.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.