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
Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use
git checkout <file>to restore the file to its original state. You can also reset all changes in the repository usinggit reset --hardcommand. Additionally, you can usegit stashandgit stash popto temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you callsubmit) usinggit statusorgit diffcommands. However you don't need to usegit addorgit commitbefore submitting your changes. In fact,submitonly submits currently unstaged changes because it usesgit diffto get the changes that need to be submitted.CHECKLIST
Before submitting your solution, please go over the following checklist and make sure you've done everything:
- If an error was reported in the issue description, I have successfully reproduced it.
- If an error was reported in the issue description, I have confirmed that my fix resolves the error.
- I have thought about edge cases and made sure my fix handles them as well.
- I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. I want you to list every bullet from this checklist and write your reasoning for why you think you did it or didn't need to.
Repository has been uploaded and your shell is currently at the repository root. Time to solve the issue!
(Current directory: /vize, current file: none) bash-$
- Assistant
I’ll inspect the SSR element code and nearby tests first, then reproduce the generated output using the repository’s existing test/build tooling before implementing a merge consistent with the root-element path.
- Assistant
The bug is confirmed in the implementation: direct element processing emits attributes independently, while the inherited-root path collects props. I’ll now inspect element traversal/order and existing v-show snapshots/test declarations so the fix avoids emitting the original style twice rather than merely adding a third merged path.
- Assistant
Attribute processing skips a static style only when
:styleexists, andprocess_v_bind_on_elementalready combines those two. The clean direct-path fix is therefore to make style emission v-show-aware in both places: static style should be deferred to v-show when there is no dynamic binding, dynamic style should include the show object itself, and bare v-show should render one style through_ssrRenderStyle. I’ll verify exact compiler output and expression conventions before editing. - Assistant
To satisfy the reported reproduction directly (including both static and bound style cases), I’ll create a temporary example binary that calls
compile_ssr, run it against nested elements (which force the buggy direct path), and remove the example after using it. This does not alter repository tests. - Assistant
The reproduction exactly matches both failure modes described. I’ll implement a single style owner for direct-path elements: defer static style when v-show is present, fold v-show into
:stylewhen present, otherwise have v-show render the static style plus conditional display object through_ssrRenderStyle. This preserves source ordering without duplicate attributes. - Assistant
The initial edit also changed code generation for bare v-show (from a conditional attribute to
style=""when visible), which is unnecessary for this bug and would churn existing snapshots. I’ll preserve the established bare-v-show output while retaining merged_ssrRenderStyleoutput only when an existing style is present. - Assistant
The post-fix reproduction now emits exactly one style attribute for static and bound styles, regardless of directive ordering, while bare v-show remains unchanged. I’ll run the crate’s full test suite and workspace lint/check relevant to the changed Rust code, then inspect the final diff and repository cleanliness.
- Assistant
All 108 crate tests and strict Clippy passed, and the temporary reproduction files are gone. One defensive refinement remains: static style should only be deferred when v-show actually has an expression, matching the collector path’s behavior and avoiding dropping style during error-tolerant compilation of a malformed bare
v-show. I’ll make that small adjustment, rerun focused verification, and 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.
Identical first prompt
Qwen/Qwen3.6-27BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →
- xiaomi/mimo-v2.5-proCompare side by side →
- xiaomi/mimo-v2.5-proCompare side by side →
- xiaomi/mimo-v2.5-proCompare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-solCompare side by side →