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
vue<template> <div class="wrapper"> <span style="color:red" v-show="ok">x</span> </div> </template>Actual
js<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 static attr or binding and merge into a single style binding, reusing the merge logic already present in the single-root path (, plain.rs:245-254). Assistant
Let me start by understanding the issue:
- The bug is in
process_v_show_on_elementincrates/vize_atelier_ssr/src/codegen/element/plain.rs - When
v-showis used on an element that already has astyleattribute or:stylebinding, it emits a duplicatestyleattribute - The fix should merge the v-show style into the existing style binding instead of adding a standalone
style="display: none;"
Let me first explore the repository structure and understand the codebase.
- The bug is in
Assistant
Good, I can see the relevant file. Let me open it to understand the code structure.
Assistant
I need to use the correct command format for opening files. Let me try with the open command without the file parameter.
Assistant
Now let me see the full file with line numbers to understand the exact locations:
Assistant
Now I have a clear understanding of the issue. Let me also look at how tests are structured in the project:
Assistant
Let me look at the existing v-show tests and snapshots:
Assistant
I need to understand the full scope of the issue. Let me continue exploring the test file and snapshots to understand the expected behavior.
Assistant
Let me look at the existing v-show test snapshots:
Assistant
Now I can see the correct behavior for the component case - it merges the v-show into the style using
_mergePropswith a style array. Let me also look at theprocess_v_bind_on_elementfunction to understand how style merging is handled there, and then understand what the fix should be.Now let me understand the issue more clearly:
-
Current behavior in
process_v_show_on_element(line 479-493): It emits(({exp}) ? "" : " style=\"display: none;\"")which is a standalonestyleattribute when the expression is false. -
Expected behavior: When the element has a static
styleattribute OR a:stylebinding, v-show should merge into a single style binding using_ssrRenderStyle. -
Reference: The
collect_element_directive_attrfunction (line 245-254) already handles v-show correctly by adding a style entry to the props that get merged via_mergeProps.
Let me check what helper functions are available:
-
Assistant
Good. Now let me understand the full picture by looking at how the
process_v_bind_on_elementhandles the style case. It already correctly handles merging static style with dynamic:styleusing_ssrRenderStyle([staticStyle, dynamicExp]).Now I need to think about the fix. The issue is that
process_v_show_on_elementemits a standalonestyleattribute. Instead, it should:- Check if the element has a static
styleattribute - Check if the element has a dynamic
:stylebinding - If either exists, use
_ssrRenderStyleto merge them together - If neither exists, the current behavior is fine
Let me look at the existing test to see what the expected behavior should be, and create a reproduction script first:
- Check if the element has a static
Assistant
Good, tests pass. Now let me write a reproduction script to confirm the issue:
Assistant
I need to create a proper test script that can be run as part of the project:
Assistant
Let me check the project structure to understand how to run a simple test:
Assistant
Now I have a good understanding of the codebase. Let me create a simple test to reproduce the issue:
Assistant
Let me add a test directly to the lib.rs to confirm the bug:
Assistant
Wait, the tests passed. That's because I'm checking for
\\\"but the actual escape in the code is different. Let me fix my reproduction test:Assistant
I see the issue with my test - I used the wrong escape. Let me look at what the actual output contains:
Assistant
The output shows the bug. I can see from the eprintln that:
- For static style:
style="color:red"${((_ctx.ok) ? "" : " style=\"display: none;\"")} - For dynamic style:
style="${_ssrRenderStyle({ color: _ctx.color })}"${((_ctx.ok) ? "" : " style=\"display: none;\"")}
Both have the duplicate
style="display: none;"issue. Let me fix my test to properly detect this:- For static style:
Assistant
Let me revert the test changes and properly fix them:
Assistant
Now I understand the bug from the output. Let me examine the current output:
Current output for static style + v-show:
code<span style="color:red"${((_ctx.ok) ? "" : " style=\"display: none;\"")}>Current output for dynamic :style + v-show:
code<span style="${_ssrRenderStyle({ color: _ctx.color })}"${((_ctx.ok) ? "" : " style=\"display: none;\"")}>Both produce TWO style attributes. Now I need to understand what the fix should look like:
For static style + v-show, the expected output should be something like:
Assistant
Assistant
Now I understand the code well. Let me implement my fix:
Plan:
-
Modify
process_element_attrsto:- Skip emitting static
stylewhen there's v-show (and no :style binding) - so v-show can merge it - Skip processing v-show directive when there's a
:stylebinding - so :style can merge it
- Skip emitting static
-
Modify
process_v_bind_on_elementforstylecase to also include v-show's style in the merge -
Modify
process_v_show_on_elementto:- When there's static style (and no :style): use
_ssrRenderStyle([staticStyle, vShowStyle]) - When there's :style: skip (handled by :style)
- Otherwise: use current behavior
- When there's static style (and no :style): use
Let me implement this:
-
Assistant
Now let me check if there's a helper function to check for v-show:
Assistant
Good, there are
has_v_showandget_v_show_expfunctions available. Now let me implement the fix.The fix approach:
-
In
process_element_attrs: When there's v-show AND no dynamic style binding, skip emitting the static style attr (so v-show can merge it). -
In
process_v_show_on_element:- If there's a
:stylebinding: Skip emission (handled by:style) - If there's static style (and no
:style): Use_ssrRenderStyle([staticStyle, vShowStyle]) - Otherwise: Use current behavior
- If there's a
-
In
process_v_bind_on_elementfor style: Also include v-show's style in the merge array.
Wait, I realize there's still an issue. If we skip v-show in when there's a , we need to know about v-show when processing . Let me think...
-
Assistant
Now let me make the changes. I'll edit the file:
Assistant
Now I have the full file. Let me implement my fix. I need to:
-
Modify
process_element_attrs(line 104-131): Skip emitting staticstylewhen there's v-show AND no:stylebinding (so v-show can handle the merge via_ssrRenderStyle) -
Modify
process_v_bind_on_elementforstylecase (line 378-390): Also include v-show's style in the_ssrRenderStylearray -
Modify
process_v_show_on_element(line 479-493):- If there's a
:stylebinding: Skip emission (handled by:style) - If there's static style (and no
:style): Use_ssrRenderStyle([staticStyle, vShowStyle]) - Otherwise: Use current behavior
- If there's a
Let me make these changes:
-
Assistant
Let me verify the changes were applied correctly:
Assistant
The
process_v_show_on_elementfunction wasn't updated. The issue is likely that my escape sequences in the Python script didn't match. Let me check what the actual content looks like:Assistant
The old pattern in my Python script had incorrect escaping. Let me directly edit this function:
Assistant
Now let me compile and test:
Assistant
I see, the
Stringtype iscompact_str::CompactStringwhich usesString::new(text)instead ofString::new(). Let me check the correct way to create an empty string:Assistant
I should use
"".to_compact_string()instead ofString::new(). Let me fix this:Assistant
The code compiles. Now let me run the existing tests to see if my changes work:
Assistant
All tests pass. Now let me write a quick test to verify the fix works for the reported issue cases:
Assistant
The test for v-show alone failed because I'm checking for the wrong escape pattern. The actual output is correct - it still emits
style="display: none;"when there's no other style. Let me fix my test:Assistant
The tests show that:
style="color:red" v-show="ok"now outputs:style="${_ssrRenderStyle(["color:red", (_ctx.ok) ? null : { display: "none" }])}"✓:style="{ color }" v-show="ok"now outputs:style="${_ssrRenderStyle([{ color: _ctx.color }, (_ctx.ok) ? null : { display: "none" }])}"✓v-show="ok"alone still outputs:${((_ctx.ok) ? "" : " style=\"display: none;\"")}✓
Let me verify the exact output is correct by looking at all test cases:
Assistant
All 108 tests pass. Now let me also test the edge case with static style + dynamic :style + v-show to make sure that works too:
Assistant
All 4 edge case tests pass. Now let me clean up the temporary tests and run the full test suite:
Assistant
Let me run all the SSR tests again to make sure everything still passes:
Assistant
Now let me check my complete changes and verify the fix is correct:
Assistant
The changes look correct. Let me now run the broader test suite to make sure nothing else is broken:
Assistant
All 108 tests pass. Let me also check if there are any other tests in the repository that might be affected:
Assistant
There's a failing test in another package. Let me check if it's related to my changes:
Assistant
This test failure is unrelated to my changes - it's about template syntax quirks handling for self-closing HTML elements, not about v-show or style merging. Let me verify this test was failing before my changes:
Assistant
Confirmed - the test was already failing before my changes. Let me restore my changes:
Assistant
Good, the failing test was pre-existing and unrelated to my changes. Let me run the SSR-specific tests one more time to confirm my fix is solid:
Assistant
All 108 SSR tests pass. Let me now review my changes one final time and submit:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.