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 the issue. The issue is about
process_v_show_on_elementincrates/vize_atelier_ssr/src/codegen/element/plain.rsthat emits a standalonestyle="display: none;"chunk instead of merging v-show into the element's existing style. I need to:- Explore the repository structure
- Look at the relevant files
- Understand the current code
- Implement the fix
- Verify the fix
Let's start by exploring the repository and looking at the relevant file.
Assistant
Let me look at the relevant file first:
Assistant
Let me try to open the file directly:
Assistant
Now let me look at the single-root path that merges correctly (lines 245-254):
Assistant
Now let me look at
process_directive_on_elementto understand how directives are dispatched:Assistant
Let me look at how elements are rendered more broadly. Let me find where the element processing starts:
Assistant
Let me search for how elements are generated:
Assistant
Let me look at the beginning of the file and understand the structure:
Assistant
Let me look at
process_plain_elementandprocess_element_attrs:Assistant
Now let me look at
process_element_attrs:Assistant
Let me look for existing tests related to v-show:
Assistant
Let me look at the SSR tests and the snapshot files:
Assistant
Let me check the existing snapshots:
Assistant
Let me look at
get_compiled_string:Assistant
Let me look at these functions:
Assistant
Let me write a small script to reproduce the issue:
Assistant
Let me find a simpler way to run the repro. Let me check if there's an example or if I can use
cargo testdirectly:Assistant
Let me add a temporary test to reproduce the issue and see the output:
Assistant
Let me check if the binary was created and run it:
Assistant
Now I've confirmed the issue. Let me look at the complete structure and implement the fix. Let me see the full
process_element_attrsand related code:Assistant
Let me check if
has_v_showis already available:Assistant
Let me check the
has_v_showfunction:Assistant
Let me check the imports at the top of
plain.rs:Assistant
Let me check the lib.rs to see what's exported:
Assistant
Let me check the codegen module:
Assistant
Let me look at the codegen directory structure:
Assistant
Let me look at
element.rs(the parent ofelement/plain.rs):Assistant
Let me look at the helpers to understand the
cstr!macro:Assistant
Let me look for the
cstr!macro:Assistant
Let me look at
quoted_js_string:Assistant
Let me look at the props module:
Assistant
Let me look at the
cstr!macro definition:Assistant
Now I have a thorough understanding of the code. Let me implement the fix.
The plan:
- In
process_element_attrs, pre-check for v-show and skip staticstyleand:stylebinding when v-show exists. - In
process_v_show_on_element, merge v-show's display:none into existing static/dynamic style using_ssrRenderStyle.
Let me first edit
process_element_attrs:- In
Assistant
Let me try a different approach. Let me use
replace:Assistant
Now let me edit
process_v_show_on_element:Assistant
Let me go to the correct line:
Assistant
Now I can see the exact code. Let me use the correct replacement:
Assistant
Let me verify the String type used in this crate:
Assistant
Now let me build and test:
Assistant
The build succeeded. Let me rebuild and run my repro:
Assistant
The rlib might not have been refreshed. Let me run the tests directly:
Assistant
Let me add a quick test to verify the fix works. Let me write a small test directly in the tests:
Assistant
Let me fix the test and use simpler assertions:
Assistant
Let me see the actual outputs:
Assistant
The fix is working correctly! All cases now produce a single
styleattribute with properly merged v-show display:none.Let me clean up the temporary test file and run the full test suite:
Assistant
Now let me run the full SSR test suite to check if existing snapshots need updating:
Assistant
All 108 tests pass. Let me also verify that I haven't introduced any warnings and check the final state of the modified file:
Assistant
Let me also check that the broader test suite doesn't break. Let me first check if there are other tests that might be affected:
Assistant
Let me verify the final state of my changes:
Assistant
The diff looks clean. Let me also run a broader test to ensure nothing else is broken:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.