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).ADDITIONAL ADVICE
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
v-showon a non-root element with an existing style attribute or:stylebinding emitting a duplicate style attribute. The fix should be inprocess_v_show_on_elementincrates/vize_atelier_ssr/src/codegen/element/plain.rs.Let me first explore the repository structure and then look at the relevant code.
Assistant
Let me look at the specific files mentioned in the issue.
Assistant
Let me look at the relevant sections. First, the reference implementation at lines 245-254 (the single-root path), and then the buggy
process_v_show_on_elementat lines 479-493.Assistant
Now let me look at
process_v_show_on_elementaround lines 470-500:Assistant
Let me understand how
process_element_attrsworks and whereprocess_v_show_on_elementis called from:Assistant
Let me look at
process_element_attrsfully:Assistant
Let me also look at
process_v_bind_on_elementand the props module to understand the full context:Assistant
Let me look at some helper functions and the props module:
Assistant
Let me look at
has_dynamic_bindto understand how it works:Assistant
Let me also check if there's a
has_directivehelper:Assistant
Let me look at the transforms module:
Assistant
Let me look at the existing tests for v-show:
Assistant
Let me look for the tests in lib.rs and the existing snapshots:
Assistant
Let me look at the test snapshot and test file for v-show:
Assistant
Let me look at the test file for v-show:
Assistant
Let me look at the test file more fully:
Assistant
Now I have a good understanding of the problem. Let me first create a reproduction script to verify the issue:
Assistant
Let me look at how
get_compiled_stringworks in tests:Assistant
Let me look at
get_compiled_string:Assistant
Now let me create a reproduce script:
Assistant
Let me run the existing tests to see how things work, and then write a quick inline test:
Assistant
Let me write a simpler reproduction using the existing test infrastructure. Let me look at how
compile_ssris exported:Assistant
Let me create a temporary test file to reproduce the issue:
Assistant
The test passed but we didn't see the output. Let me run with
--nocapture:Assistant
Now I've confirmed the issue. Both cases produce duplicate
styleattributes. Let me implement the fix. Let me first check what's already imported in plain.rs:Assistant
Let me check what's available from
super::*:Assistant
Let me check the parent module:
Assistant
Let me look at the codegen module structure:
Assistant
Let me look at the element.rs (the parent module for plain.rs):
Assistant
Let me check how
has_v_showis imported in the codegen:Assistant
Let me look at how lib.rs organizes things:
Assistant
Now let me look at the helpers module:
Assistant
Let me check the helpers file:
Assistant
Let me check what's in the helpers file and where
quoted_js_stringis:Assistant
Now I have enough understanding. Let me implement the fix. Here's my plan:
- In
process_element_attrs, add detection forhas_v_showand skip staticstyleattribute when v-show is present. - In
process_directive_on_element, skip:stylebind when v-show is present (sinceprocess_v_show_on_elementwill handle it). - In
process_v_show_on_element, compute a merged style expression using_ssrRenderStyle.
Let me implement this:
- In
Assistant
Now let me look at the full
process_directive_on_elementagain:Assistant
Now let me implement the fix. I'll modify three sections:
process_element_attrs- skip static style when v-show is presentprocess_directive_on_element- skip:stylebind when v-show is presentprocess_v_show_on_element- merge all styles into a single style attribute
Let me first edit
process_element_attrs:Assistant
Let me use the edit command properly:
Assistant
Let me make sure the right file is open:
Assistant
The
opencommand is trying to execute the file as a script. Let me use the full path withopen --fileoption. Let me look at the special commands again:Actually, looking at the documentation again,
opentakes a FILE path. Let me try:Assistant
Now let me edit the
process_element_attrsfunction:Assistant
Let me try using the
--fileoption:Assistant
I see there's a duplicate comment. Let me fix that first:
Assistant
Good. Now let me modify
process_directive_on_elementto skip:stylewhen v-show is present. Let me look at its current location:Assistant
Now I need to modify
process_v_bind_on_elementto skip:stylewhen v-show is present. Let me look at the exact code:Assistant
Now let me modify the
stylebranch inprocess_v_bind_on_elementto skip when v-show is present:Assistant
I see the edit introduced problems - there's duplicate code. Let me look at the full current state:
Assistant
The edit corrupted the file. Let me revert and redo:
Assistant
Good, now let me verify the file is restored and redo the changes more carefully:
Assistant
Let me use smaller, targeted
replaceoperations. First, let me add thehas_v_showvariable:Assistant
Let me navigate to the right location first:
Assistant
Now let me do the replace operations one by one:
Assistant
Let me use the multi-line heredoc syntax for
replace:Assistant
Good, now let me modify the condition to skip static style when v-show is present:
Assistant
Now I need to modify
process_v_bind_on_elementto skip:stylewhen v-show is present. Let me navigate to the style branch:Assistant
Now let me replace the
:stylebranch inprocess_v_bind_on_elementto skip when v-show is present:Assistant
Now the most important part: modifying
process_v_show_on_element. Let me navigate to it:Assistant
Now let me replace the
process_v_show_on_elementfunction:Assistant
Let me now run the reproduction test to see if the fix works:
Assistant
The fix works! Both cases now show a single
styleattribute. Let me also update the repro test to verify the edge cases:Assistant
Let me run the updated test:
Assistant
All test cases pass. Now let me run the existing tests to make sure nothing is broken:
Assistant
All 68 tests pass. Let me clean up the temporary repro test file:
Assistant
Let me check if the existing snapshots need updating:
Assistant
Let me verify the final diff:
Assistant
The diff looks correct. Let me run the full test suite one more time to confirm everything passes:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.