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).Interface
No new interfaces are introduced.
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 start by exploring the repository structure and understanding the codebase, then look at the specific file mentioned in the issue.
Assistant
Let me look at the relevant file mentioned in the issue.
Assistant
Now I understand the structure. Let me look at the relevant functions more closely. Let me first understand how
process_v_bind_on_elementhandles thestylecase (lines 419-435) since that's the pattern I need to follow, and the helper functions used.Assistant
I need to make single tool calls. Let me search for the helper functions and understand the structure.
Assistant
Let me look at the
process_v_bind_on_elementforstylemore closely and how the merge logic works. Let me also look at the helpers and check existing tests for v-show.Assistant
Let me look at the snapshot for this test and understand the expected output format.
Assistant
Now I can see the component merge path (single-root) which uses
_mergePropswithstyle: ["color: red;", ((_ctx.ok) ? null : { display: "none" })]. Let me look at the SSR snapshot test file and the v-show fixtures to understand more.Assistant
Let me look at how
normalize_prop_entriesandcomponent_prop_entrywork, since the single-root path relies on them to merge duplicatestylekeys.Assistant
Let me look at the v-show test fixtures and expected snapshots to understand desired behavior.
Assistant
Let me reproduce the bug. First, let me check how to run the existing SSR tests and write a reproduction.
Assistant
Now let me create a temporary reproduction test to confirm the bug:
Assistant
The dependencies are being downloaded. Let me wait for the build to complete.
Assistant
I've confirmed the bug — all three cases produce 2
style=attributes. Now let me check what helpers are available for detecting v-show in the codegen path.Assistant
Let me look at the
_ssrRenderStyleruntime helper to ensure it handles arrays withnullentries correctly.Assistant
Let me look at the v_bind_style snapshot to confirm
_ssrRenderStylehandles arrays.Assistant
I've confirmed the bug. Now let me implement the fix. First, let me view the exact current text of the three areas I need to modify.
Assistant
Now let me make the edits. First,
process_element_attrs— addhas_v_showdetection and skip the staticstyleattribute when v-show will handle the merged style:Assistant
I need to navigate to the line first. Let me open the file at the relevant location.
Assistant
Edit 1 done. Now Edit 2 —
process_v_bind_on_elementSome("style") branch: skip emission when v-show will handle the merged style. Let me navigate to that area.Assistant
Edit 2 done. Now Edit 3 — rewrite
process_v_show_on_elementto merge existing styles. Let me navigate to it.Assistant
Now let me rewrite
process_v_show_on_elementto merge existing styles into a single binding:Assistant
Now let me verify
merge_prop_valuesis accessible and the file compiles. Let me check the imports and build.Assistant
merge_prop_valuesispub(super)and imported viause super::props::*. Now let me run my reproduction tests to confirm the fix works.Assistant
All three cases now produce exactly one
style=attribute, matching the Vue patternstyle=[existing, expr ? null : {display:'none'}]. Let me test additional edge cases: ordering variations, the no-style standalone case, and v-show without an expression.Assistant
Excellent! All edge cases pass. Let me also test the root-level (single-root / inherit_attrs) path and the v-show-without-expression edge case to ensure no regressions.
Assistant
Let me see the failure details for the root-level cases.
Assistant
The root-level failures are just my test assertions being wrong — the root (single-root/inherit_attrs) path uses
_mergeProps({ style: [...] }, _attrs)which rendersstyleat runtime via_ssrRenderAttrs, so there's no literalstyle=(count 0, which is correct). This path already worked correctly per the issue. Let me fix my temp test assertions to verify the right thing.Assistant
All 13 tests pass. Now let me remove the temporary test file and run the existing SSR test suite to ensure no regressions.
Assistant
All 68 existing SSR tests pass. Let me run clippy to ensure no lint warnings (the crate enables
clippy::all).Assistant
Clippy passes with no warnings. Let me check whether there are broader integration tests (in
tests/) that exercise SSR v-show + style that might be affected.Assistant
No SSR fixtures exist in
tests/(only vdom/vapor). The SSR-specific tests are all incrates/vize_atelier_ssr/tests/and pass. Let me do a final review of the complete diff.Assistant
The diff is clean and correct. Let me verify no temporary files remain and run the full SSR test suite one final time to confirm everything is green.
Assistant
Everything is clean and complete. Let me provide a final summary of the checklist before submitting.
Checklist
-
[x] Reproduced the error: I created a temporary test that confirmed the duplicate
style=attribute (2 occurrences) for<span style="color:red" v-show="ok">,<span v-show="ok" :style="{ color }">, and the both-styles case. The output was<span style="color:red"${((_ctx.ok) ? "" : " style=\"display: none;\"")}>— exactly the bug described. -
[x] Confirmed the fix resolves the error: After the fix, all three cases emit exactly one
styleattribute via_ssrRenderStyle(["color:red", ((_ctx.ok) ? null : { display: "none" })])— matching Vue'sssrTransformShowpatternstyle=[existing, expr ? null : {display:'none'}]._ssrRenderStyleignoresnullwhen shown (existing style preserved) and rendersdisplay:nonewhen hidden, so hiding now works. -
[x] Considered edge cases: Tested ordering variations (style before/after v-show — both produce identical correct output), static-only, dynamic-only, both, no-style standalone (preserved exactly as before), other attrs like
idpreserved, comparison expressions (count > 0), class still merged correctly alongside style, nested v-show (one style per element, no duplicates), and the root/single-rootinherit_attrspath (unchanged — already correct via_mergeProps). The skip logic is gated onget_v_show_exp(el).is_some()(not justhas_v_show) so a hypothetical v-show-without-expression doesn't drop an existing:style/static style. -
[x] Ran existing affected tests: All 68
vize_atelier_ssrtests pass (includingv_show::basic_v_showandv_show::v_show_with_other_attrssnapshots, which are unchanged since the no-existing-style standalone path is preserved), andcargo clippyis clean.
The fix has three coordinated parts in
crates/vize_atelier_ssr/src/codegen/element/plain.rs:process_element_attrs— skip the staticstyleattribute when v-show is present.process_v_bind_on_element(:stylebranch) — return early when v-show owns the merged style.process_v_show_on_element— inspect for existing staticstyle/:style, and when present emit a single mergedstyle="${_ssrRenderStyle([existing..., (expr ? null : {display:"none"})])}"binding; otherwise preserve the standalone conditional behavior.
-
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
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.5-35B-A3BCompare side by side →
Qwen/Qwen3.5-35B-A3BCompare side by side →