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
I'll start by exploring the repository structure and understanding the codebase, then locate and fix the issue.
Assistant
Good, I found the relevant file. Let me open the
plain.rsfile to understand the issue.Assistant
The open command needs a different syntax. Let me just use cat to view the file first.
Assistant
Let me continue reading the file to find the relevant sections mentioned in the issue.
Assistant
I found the correct merge logic in lines 245-254. Now let me look at the
process_v_show_on_elementfunction around line 490.Assistant
Perfect! I found the buggy function at lines 479-493. The issue is clear:
process_v_show_on_elementunconditionally emits a standalonestyle="display: none;"chunk, which creates duplicate style attributes when there's already a style attribute or binding.Let me understand the context better by looking at the whole file structure:
Assistant
Found the
component_prop_entryfunction and how it works. Now let me see the full context ofcollect_element_directive_attrto understand how v-show is handled in the single-root path.Assistant
Now I understand the issue. The
collect_element_directive_attrfunction correctly handles v-show by adding a style entry (lines 245-254), which gets merged properly. However,process_v_show_on_element(lines 479-493) emits a standalone style attribute instead of merging it.Let me look at where
process_v_show_on_elementis called:Assistant
Now let me check where
process_element_attrsis called to understand the flow:Assistant
Now I understand the problem better. The
process_v_bind_on_elementfunction (lines 343-407) handles:stylebinding by checking if there's a static style and merging them. Similarly, I need to fixprocess_v_show_on_elementto handle the case when there's already a style attribute or:stylebinding.Let me look at the helper functions to understand how to check for existing style:
Assistant
Good! Now I have a clear understanding. Let me check the imports and helper functions used in this file:
Assistant
Let me look at what helpers are available in the super module:
Assistant
Now let me look at the tests to understand the expected output format:
Assistant
Let me check the SSR snapshot tests to understand the expected behavior.
Assistant
Now let me look at the snapshot files to see the expected output format. Let me also search for v-show related tests.
Assistant
Let me check the current snapshot output for v-show tests:
Assistant
This confirms the issue! The output has a duplicate style attribute. Let me check the other v-show snapshots:
Assistant
I need to understand the problem better. The issue is that when there's a static
styleattribute or a:stylebinding, the current code emits a separate style attribute for v-show, resulting in duplicate style attributes. Let me check what the correct behavior should be by looking at how Vue handles this.Let me look at the component v-show test to see how it's handled correctly there:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.