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
Assistant
Let me start by exploring the repository structure to understand the codebase.
Assistant
Now let me look at how
process_v_show_on_elementis called to understand the context:Assistant
Now let me look at
process_v_bind_on_elementand how it generates the style attribute, and how single-root works:Assistant
Now let me check the test snapshots:
Assistant
Let me see how this currently works in a non-root context:
Assistant
Let me also check
has_dynamic_bindandget_dynamic_bind_exp:Assistant
Let me look at the SSR style helper to understand the expected output shape:
Assistant
Let me look at how Vue's actual
ssrTransformShowhandles this. First, let me write a reproducer to confirm the issue:Assistant
Let me write a reproducer in a temporary file:
Assistant
Good, builds. Let me check existing test infrastructure to verify my understanding:
Assistant
Now let me create a temporary test file to confirm the bug:
Assistant
Now I've confirmed the bug. Let me look at the existing helpers and existing
get_v_show_expfunction:Assistant
Good —
get_v_show_expexists and returnsOption<&ExpressionNode>. I can use this to get the expression.Now let me look at
quotted_js_stringto ensure my new code matches existing style:Assistant
Now let me look at relevant helpers:
Assistant
Let me check if there are other callers of
process_directive_on_elementorprocess_v_bind_on_element:Assistant
Let me check if
CompactStringis available:Assistant
Good —
use vize_carton::{FxHashSet, String, ToCompactString}. Let me check if CompactString is available:Assistant
Good. Now let me check existing helpers and how the existing
:style_ssrRenderStylecall works:Assistant
Let me check the return type of
expression_to_string:Assistant
OK so
expression_to_stringreturnsString(which isvize_carton::String=CompactStringhere, an alias). Let me confirm:Assistant
Let me look at
cstr!to understand its semantics withCompactString:Assistant
Let me check
quotted_js_stringonce more for context:Assistant
Let me write the fix. First, let me look at the current code surrounding the changes I'll make:
Assistant
Now I have enough context. Let me make the fix. First, let me modify
process_element_attrs:Assistant
Let me verify the change:
Assistant
Let me look at the current state of those functions to verify:
Assistant
Now let me modify
process_directive_on_elementto accept the v_show_exp:Assistant
Now let me modify
process_v_bind_on_elementto accept and use v_show_exp:Assistant
Let me fix the comment typo from escaped quote:
Assistant
Let me look for the escaped quote to clean it up:
Assistant
Now let me also fix the same issue elsewhere:
Assistant
Now let me modify
process_v_show_on_element:Assistant
Let me use a different approach with sed since Python escaping is tricky:
Assistant
Now let me try to build:
Assistant
CompactString::newtakes 1 argument. Let me fix:Assistant
CompactString::newtakes aT: AsRef<str>argument. So I need to pass an empty string. Let me use:.unwrap_or_else(|| CompactString::new(""));Or:
.unwrap_or_else(|| CompactString::default());Let me check if default works.
Assistant
Now let me try building again:
Assistant
Build successful. Now let me run the reproducer:
Assistant
Excellent! The fix is working:
- Test 1 (static
style): Now emits a singlestyle="..."via_ssrRenderStyle([static, (ok) ? null : {display:'none'}])— single style attribute with proper merge. - Test 2 (
:stylebinding): Single style attribute with the bound expression ANDdisplay:nonemerge. - Test 3 (no style): Original behavior preserved — single
stylechunk. - Test 4 (root element with v-show): Unchanged (different single-root path).
Let me run the existing tests to ensure nothing broke:
- Test 1 (static
Assistant
All tests pass. Now let me also verify a few more edge cases by adding them to my reproducer:
Assistant
All cases work correctly. Let me also run a broader test to ensure nothing else broke:
Assistant
Some tests are failing. Let me check the SSR-related failures:
Assistant
Those failures are environmental ("failed to start pkl server"). They are unrelated to my changes. Let me check the others:
Assistant
This test is also unrelated to my fix - it's about warning for self-closing HTML. Not affected by my SSR fix.
Let me also check the other failures:
Assistant
These are also unrelated failures (TS config loader, pkl server). Let me run just the SSR test suite:
Assistant
All 68 SSR tests pass. Let me also check the broader snapshot tests in the SSR suite:
Assistant
All 68 tests in vize_atelier_ssr pass. Let me also check that the related atelier_dom tests pass (since this affects v-show behavior):
Assistant
Let me verify those failures are environmental, not related to my fix:
Assistant
Confirmed environmental (pkl server missing). Let me also look at what
vize_atelier_sfchas for v-show test fixtures:Assistant
Let me verify the final state of the file:
Assistant
Now let me run my edge case reproducer one more time to verify everything still works:
Assistant
All edge cases pass. Now let me also verify by running the SSR-specific snapshot tests:
Assistant
All SSR tests pass. Now let me also check the diff to make sure my fix is clean:
Assistant
Let me clean up my temporary test files:
Assistant
Let me verify the final state of my changes once more:
Assistant
Let me run the full SSR test suite one more time to ensure everything works:
Assistant
All 68 SSR tests pass, including the
v_show::basic_v_showand component tests. Let me also run a quick sanity test by creating a temporary script to verify the original issue from the description is fully fixed:Assistant
The fix is fully working. Let me clean up:
Assistant
Now let me do a final review by listing my changes against the checklist:
Checklist Review:
-
Reproduced the error: ✅ I confirmed the bug with a reproducer script. The original
<span style="color:red" v-show="ok">x</span>emitted twostyleattributes (browser keeps first, v-show fails to hide). -
Confirmed fix resolves the error: ✅ After my fix, the output is a single
style="${_ssrRenderStyle(["color:red", (ok) ? null : {display:'none'}])}"— exactly one style attribute with proper merge. -
Considered edge cases: ✅ Tested many edge cases including:
styleattr + v-show (issue case):stylebinding + v-show (issue case)- v-show before style attr (reversed order)
- v-show before
:style(reversed order) - Both
styleattr + + v-show
-
Assistant
All SSR tests pass. Let me give a final summary of my changes:
Summary
The bug was in
crates/vize_atelier_ssr/src/codegen/element/plain.rswhereprocess_v_show_on_elementwas unconditionally emitting a standalonestyle="display: none;"chunk without checking if the element already had astyleattribute or:stylebinding. This caused twostyleattributes to appear on the resulting HTML tag, and the HTML parser keeping only the first, which silently dropped v-show'sdisplay: none.Fix
The fix uses the same merge strategy as the single-root path ( at line 245):
Assistant
The diff looks clean and complete. Let me submit:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.