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 repository structure and then look at the specific files mentioned in the issue description.
The issue is about
process_v_show_on_elementincrates/vize_atelier_ssr/src/codegen/element/plain.rsaround line 490. It unconditionally appends 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.Let me explore the codebase and understand the fix needed.
Assistant
Let me open the file and look at the relevant sections.
Assistant
Let me use the proper command format.
Assistant
Let me just use the regular open command.
Assistant
Now let me look at the reference implementation in
collect_element_directive_attraround lines 245-254Assistant
Now let me look at how
process_v_show_on_elementis called and the broader context of element renderingAssistant
Let me see the calling context around line 327.
Assistant
Now let me understand how static attributes like
styleare rendered for elements. Let me look at how the element rendering pipeline worksAssistant
Let me look at the full rendering flow, starting from the beginning of the file
Assistant
Now let me look at
process_element_attrsto understand how attributes are processedAssistant
Let me see the process_element_attrs function.
Assistant
Let me understand how
push_string_part_staticandpush_string_part_dynamicwork, and look at the broader codegen infrastructure.Assistant
Let me find the definition of these methods.
Assistant
Let me look at the codegen context to understand the string parts structure
Assistant
Now I have a good understanding of the issue. Let me look at the imports and helpers available
Assistant
Let me look at the props module and helpers
Assistant
Let me check the imports and the
quoted_js_stringfunctionAssistant
Let me check the module structure
Assistant
Let me look at the codegen module to understand the imports.
Assistant
Let me look at element.rs to understand the imports.
Assistant
Let me look at
element.rsinside theelementdirectory to understand the re-exports.Assistant
Now let me first create a reproduction script and then implement the fix. Let me check if there are existing tests I can run
Assistant
Let me look at existing tests and search for v-show tests
Assistant
Let me look at the v-show test section in the test
Assistant
Let me find the snapshot files for v-show
Assistant
Let me view the existing snapshots to understand the current behavior
Assistant
Hmm interesting. So for a basic v-show (no existing style), it emits
style="display: none;"which works fine. There's no duplicate because there's no other style.Now let me look at the
v_show_with_other_attrstest and see what happens when there's astyleattribute.Assistant
Let me find the
get_compiled_stringhelper functionAssistant
Let me see the test helpers.
Assistant
Let me first run the existing tests to see the current state
Assistant
Now let me create a reproduction script to confirm the bug exists
Assistant
Let me use a different approach to reproduce - I'll create a quick test using the existing test infrastructure
Assistant
Let me add a temporary test to reproduce the bug
Assistant
Let me create a temporary script that reproduces the
Assistant
I see - the single-root path uses
_mergePropswhich works correctly. Let me reproduce with the actual issue scenario (element inside a wrapper, which uses the non-inherit path)Assistant
The tests passed but I didn't see the output. Let me force them to show output
Assistant
Let me try with
--show-outputAssistant
Let me modify the test to panic and show the
Assistant
The bug is confirmed! The output shows:
html<span style="color:red"${((_ctx.ok) ? "" : " style=\"display: none;\"")}>This generates two
styleattributes whenokis false. Let me also verify the:stylecase:Assistant
Now I have confirmed the bug. Let me clean up the repro test and implement the fix.
Assistant
Now let me implement the fix. I'll modify
process_element_attrsto merge v-show with existing style attributes instead of emitting a duplicatestyleattribute.Assistant
Now let me implement the fix. I'll replace the
process_element_attrsfunctionAssistant
Let me try with the replace command using the multi-line syntax
Assistant
Let me check the rest of the modified function
Assistant
The edit looks good. Let me now compile and test
Assistant
All existing tests pass. Now let me verify the fix works with my reproduction
Assistant
The static style case now correctly produces a single merged style. Let me verify the
:stylecaseAssistant
Let me verify more edge cases - v-show only, and v-show with both static style + :style
Assistant
All cases work correctly. Let me run the full test suite to make sure nothing else is broken
Assistant
All 68 tests pass. Let me verify the snapshots haven't changed for the v-show
Assistant
Let me also check the basic snapshot still matches
Assistant
Let me make sure there are no other callers of
process_v_show_on_elementorprocess_directive_on_elementthat I might haveAssistant
Let me do a final review of the modified function to make sure everything looks
Assistant
Let me also verify the skip logic and fallthrough
Assistant
The code looks correct. Let me run the full test suite one more time to confirm
Assistant
All 68 tests pass. Let me verify my changes one final time with a summary of what changed
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.