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
Let me look at more context around
process_v_bind_on_elementandprocess_element_attrs:Assistant
Now let me check the existing tests and how the SSR transformation is done:
Assistant
Let me look at the codegen context to understand the state management:
Assistant
Let me see how the codegen context helpers work:
Assistant
Now let me look at how the snapshots are generated and how
get_compiled_stringworks:Assistant
Let me check the existing imports and types:
Assistant
Let me first write a script to reproduce the issue:
Assistant
Let me create a test script to reproduce the issue:
Assistant
Let me check the snapshot file format and write a quick reproducer using the existing test infrastructure:
Assistant
Let me write an example file inside the SSR crate to reproduce the issue:
Assistant
Now I've confirmed the bug. Let me design the fix:
Assistant
Now I'll implement the fix. Let me start by modifying the
SsrCodegenContext:Assistant
Now I'll add the
pending_v_show_style_mergesfield. Let me update the codegen context:Assistant
Let me use a different approach to modify the file:
Assistant
Now let me modify
plain.rsto implement the fix:Assistant
Now I'll modify the relevant functions in
plain.rs:Assistant
Let me simplify the modifications with separate, cleaner Python scripts:
Assistant
Now patch
process_v_bind_on_elementto skip:stylewhen merge is pending:Assistant
Now patch
process_v_show_on_element:Assistant
The escape pattern in the file uses
\\(literal\\in the source). Let me fix my Python script.Assistant
Now let me build to check for syntax errors:
Assistant
Let me verify the modifications by looking at the file:
Assistant
Let me now build and test the fix:
Assistant
The fix works. Let me also test the case where v-show is alone:
Assistant
I notice an edge case bug: when v-show has no expression, my fix is dropping the static
styleattribute. Let me fix that:Assistant
Now let me run the existing tests to make sure nothing is broken:
Assistant
All tests pass. Let me verify the existing snapshots are still correct:
Assistant
Let me check the existing v-bind style test output too:
Assistant
Now let me check that
_elparameter convention doesn't cause issues, since I renamed it to be used. Let me also handle a potential issue with the helper function imports:Assistant
Let me also check there are no clippy issues:
Assistant
Let me test additional edge cases:
Assistant
Let me look at
normalize_prop_entriesto understand the ordering:Assistant
Let me run the tests one more time to confirm everything still works:
Assistant
Let me view the final state of my changes to make sure everything is good:
Assistant
Looking good. Let me also check the codegen.rs for the field:
Assistant
Let me clean up the temporary example file before submitting:
Assistant
Let me do a final verification by running the tests one more time:
Assistant
All 68 snapshot tests pass. Let me also run the unit tests in the codegen module and the main test:
Assistant
Let me view the final summary of my changes:
Assistant
Let me do one final verification using the exact reproduction from the issue:
Assistant
I found a bug in my fix! Let me fix it:
Assistant
Excellent! Now both cases produce a single
styleattribute. Let me re-run all the edge cases:Assistant
Let me run all the existing tests one more time to ensure nothing else is broken:
Assistant
All tests pass. Let me verify the existing snapshots haven't changed:
Assistant
Let me clean up the example directory:
Assistant
Let me run the tests one more time to ensure everything still works after the cleanup, and run clippy to make sure no warnings:
Assistant
Let me view the final state of the fix:
Assistant
Let me also test a few more edge cases to ensure full coverage:
Assistant
All edge cases work correctly. Let me clean up:
Assistant
All checks are complete. Let me do a final summary of the work:
Checklist:
-
Issue reproduced ✅: I created a reproduction example that confirmed the bug —
<span style="color:red" v-show="ok">x</span>was emitting twostyleattributes. -
Issue fixed ✅: After my fix, the same input emits a single merged
style="${_ssrRenderStyle([...])}"attribute. -
Edge cases considered ✅: I tested multiple scenarios:
- v-show alone (no style) — legacy behavior preserved
- v-show + static
style— merged - v-show +
:stylebinding — merged - v-show + both static and
:style— merged - v-show without expression — static
stylepreserved - v-show before
:style(Issue B) — merged correctly - v-show after
:style— merged correctly - Nested elements — each processed independently
- Sibling elements with same pattern — each gets its own merged
style - input with v-model + v-show + style — merged
- textarea with style + v-show — merged
- Custom component with style — unchanged (uses inherit_attrs path)
- Sibling elements sharing structure — each processed independently
-
Existing tests pass ✅: 40 unit tests + 68 snapshot tests all pass.
Implementation summary:
- Added
pending_v_show_style_merges: FxHashSet<usize>toSsrCodegenContext(codegen.rs). - Modified
process_element_attrs(plain.rs:104): pre-detects the v-show + style merge case, suppresses standalone staticstyleemission, and cleans up the merge flag at end. - Modified
process_v_bind_on_element's:stylearm (plain.rs:419): suppresses standalone:styleemission when a merge is pending. - Modified
process_v_show_on_element(plain.rs:535): emits a single_ssrRenderStyle([parts])chunk when merge is pending; falls back to the legacy standalonestyle="display: none;"chunk otherwise. - Added helper
has_v_show_directive(plain.rs:162): checks for av-showdirective that has an expression (so v-show without an expression is left as a no-op and its staticstyleis rendered unchanged).
-
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 →