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
Let me start by exploring the repository structure to understand the codebase.
Assistant
Now let's look at how
process_v_show_on_elementis called from the rest of the codebase. Let me search for it.Assistant
Let me look at the
process_element_attrsfunction:Assistant
Now let me look at the v-bind processing for style to understand how it currently processes:
Assistant
Let me look at the
_ssrRenderStylehelper and howv-showshould be transformed.Assistant
Now let me check how Vue's actual SSR
ssrTransformShowworks to understand the expected behavior:Assistant
Let me look at related helper functions and the
has_dynamic_bindfunction.Assistant
Let me look at the props.rs to understand the related structures:
Assistant
Let me look at the snapshots for v-bind style:
Assistant
Let me check existing tests around v-bind with static style:
Assistant
Let me also check how
cstr!works for code formatting:Assistant
Let me check
push_string_part_staticandpush_string_part_dynamic:Assistant
Let me first try to build and verify the current behavior:
Assistant
Now let me create a small reproduction test:
Assistant
Let me create a small example:
Assistant
Let me look at how component_props_object handles multiple style entries:
Assistant
Let me look at the existing
quoted_js_stringandprocess_v_bind_on_elementmore carefully:Assistant
Let me look at the helpers again and what other helpers exist:
Assistant
Good. Now I have everything I need. Let me write the fix:
Assistant
Now let me implement the fix. First, modify
process_element_attrsto detect v-show:Assistant
I see duplicate
continue;lines. Let me fix that:Assistant
I have a duplicate
push_string_part_static(" ");. Let me fix that:Assistant
The edits are messy. Let me restart with a clean replacement of the section:
Assistant
I see the file is in a broken state. Let me just check what the current line 127 looks like. The issue is on line 127 there's still no
if (...) {line, it's justcontinue;. Let me look at line 126-127.Assistant
I see the file is corrupted. Let me restore it and try again:
Assistant
Good. Now let me edit properly:
Assistant
The edit overwrote some lines. Let me restore and rewrite cleanly:
Assistant
Now let me do replace properly to add
has_v_show:Assistant
Now
process_element_attrsis correctly updated. Let me updateprocess_v_show_on_elementto properly handle the merge cases:Assistant
Now I need to update
process_v_bind_on_elementfor the:stylecase to merge v-show if present:Assistant
Now let me build to confirm everything compiles:
Assistant
Now let me run my reproduction script to see if it works:
Assistant
Excellent! All cases now produce exactly ONE
styleattribute! Let me test the original repro case from the issue:Assistant
The exact case from the issue now produces a single style attribute with merged display:none. Let me now think about edge cases:
- What if v-show is on an element without a closing space before it? Like
<div v-show="ok">. Let me check. - What about the order of props in the template? Let me check various orderings.
- What about custom directives on the same element?
- What if v-show is on an element without a closing space before it? Like
Assistant
The duplicate style attribute case is a syntax error which is fine. Let me also test the root element case (
<div v-show="ok" style="color:red">x</div>) to make sure the inherit_attrs path also works.Assistant
All non-root cases work correctly. Now let me check the root element case:
Assistant
All root-level cases produce a single
styleattribute via the_mergePropspath. Let me run the existing tests to verify nothing is broken:Assistant
All 68 tests pass. Let me also check the final result:
Assistant
Now let me run the broader workspace tests:
Assistant
Let me check if the failing test is related to my changes:
Assistant
The failing test is pre-existing and unrelated to my fix. Let me verify the v-show tests specifically still pass and double check that the existing v-show test snapshot is still correct:
Assistant
Good. The existing v-show tests still produce the same output as before since they don't have any style attribute. Let me also check the v-bind style snapshot still has the same output:
Assistant
Let me also test the class case to make sure my changes don't accidentally affect it:
Assistant
Good. The class behavior is unchanged. Now let me also verify that my fix doesn't affect anything else when
:stylehas modifiers or non-standard arg:Assistant
Let me also test the component case to make sure I don't break that:
Assistant
All component cases work correctly with
_mergeProps. Now let me make sure I haven't broken anything else with a wider test run:Assistant
All tests pass. Now let me also examine the line numbers in my changes:
Assistant
Now let me clean up the example file (since it was a temporary test, not a real test):
Assistant
Good. Now let me also look at the final state and any clippy issues:
Assistant
No clippy issues. Let me now do a final test with the full SSR snapshot test suite to make sure everything is working:
Assistant
All 108 tests pass (40 lib + 68 snapshot tests). Let me look at the final state of the diff once more to confirm what I've changed:
Assistant
Let me also run the whole workspace tests except for the pre-existing failing test:
Assistant
Those failures are pre-existing (Pkl server missing) and unrelated to my changes. Let me confirm:
Assistant
Same number of failures (8 failed) with and without my changes - confirmed pre-existing. My changes don't break anything.
Let me also verify the SSR tests one more time:
Assistant
All 108 SSR tests pass. Let me verify my fix once more with a quick reconstruction test using a temp file (already removed):
Assistant
The exact issue case now produces a single
styleattribute with the mergeddisplay: none. Let me verify cleanup:Assistant
Only the
plain.rsfile is modified. Let me review my final changes once more:Assistant
Let me do a final pass to confirm my changes work and the tests are passing:
Assistant
All 108 tests in
vize_atelier_ssrpass.Now let me write up my checklist reasoning:
Checklist:
-
If an error was reported in the issue description, I have successfully reproduced it.
- ✅ YES. I created a temporary example script that compiled the reproduction case
<span style="color:red" v-show="ok">and confirmed the buggy output with twostyleattributes. After my fix, the output is now a single mergedstyleattribute via_ssrRenderStyle.
- ✅ YES. I created a temporary example script that compiled the reproduction case
-
If an error was reported in the issue description, I have confirmed that my fix resolves the error.
- ✅ YES. After the fix, all the cases produce a single
styleattribute:<span v-show="ok">→ existing standalone chunk (correct fallback)<span style="color:red" v-show="ok">→_ssrRenderStyle(["color:red", (ok ? null : {display:"none"})])<span :style="{color}" v-show="ok">→_ssrRenderStyle([{color}, (ok ? null : {display:"none"})])<span style="color:red" :style="{background}" v-show="ok">→_ssrRenderStyle(["color:red", {background}, (ok ? null : {display:"none"})])
- ✅ YES. After the fix, all the cases produce a single
-
I have thought about edge cases and made sure my fix handles them as well.
- ✅ YES. Edge cases considered and tested:
:classis unaffected (verified).v-bind="obj"without arg is unaffected (uses_ssrRenderAttrs).:stylewith array literal e.g.[base, extra]works:_ssrRenderStyle([[base, extra], vShowExpr]).- Reverse attribute order
<span v-show="ok" style="...">works correctly. - Root element (using
inherit_attrs=truepath via_mergeProps) was already working and remains working. - Component elements (
<MyComp v-show="ok">) use_mergePropsand work correctly with the existingcollect_element_directive_attrlogic.
- ✅ YES. Edge cases considered and tested:
-
I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass.
- ✅ YES. All 108 existing tests in
vize_atelier_ssrpass: 40 lib tests + 68 snapshot tests. The pre-existing failing tests invize_atelier_sfc(Pkl server missing) andvize(template syntax quirks test) are unrelated to my changes—they fail both before and after.
- ✅ YES. All 108 existing tests in
Let me do a final review of my code one more time:
-
Assistant
All looks good. Let me also check the helper trait functions:
Assistant
Good. The helpers are accessible via
crate::has_v_showandcrate::get_v_show_exp(matching the existing pattern in the file).Let me also check the
lib.rsexports to be sure:Assistant
Let me also do one more sanity check with
:classand v-show together since they could possibly interact with my change inprocess_v_bind_on_element:Assistant
All edge cases work correctly:
:classwith v-show: still produces correct class + standalone display:none- Multiple attributes with v-show: handles each correctly
- Boolean attribute with v-show: works correctly
Now let me clean up the example directory:
Assistant
Only the expected file is modified. Let me do one final test pass to confirm:
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 →