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
v-showdirective on non-root elements with existingstyleattributes or:stylebindings emitting duplicatestyleattributes. I need to find the relevant files and understand the codebase.Let me first explore the repository structure.
Assistant
Let me look at the relevant file mentioned in the issue:
Assistant
The open command needs the path. Let me check if the file exists.
Assistant
Let me open the file.
Assistant
Let me look at the
process_v_show_on_elementfunction and the surrounding code:Assistant
Now let me look at the single-root /
collect_element_directive_attrpath mentioned in the issue:Assistant
Let me understand how
process_v_show_on_elementis called. Let me search for its callers:Assistant
Let me look at the context around line 327
Assistant
Let me find the
process_element_attrsfunction:Assistant
Let me look at the
process_element_attrsfunction starting at line 104.Assistant
Let me look at how
process_v_bind_on_elementhandles style:Assistant
Let me search for existing tests related to v-show SSR to understand the expected output format:
Assistant
Let me look at the SSR snapshot tests for v-show:
Assistant
Let me look at the component test for v-show with style merging:
Assistant
Let me look at the SSR test file for v-show tests:
Assistant
Let me look at the v-show test cases more fully:
Assistant
Let me search for test cases that combine v-show with style:
Assistant
Let me look at how the SSR compilation and testing infrastructure works:
Assistant
Let me create a reproduction script:
Assistant
Let me check how to build and run the reproduction:
Assistant
Let me look at the transforms module mentioned in the search results:
Assistant
Let me try building the relevant crate:
Assistant
Let me create a quick test to see the actual output:
Assistant
Let me create a temporary script to reproduce the issue:
Assistant
Let me just add a quick diagnostic test to the test file to see the current output:
Assistant
Let me find the lib tests to understand the testing pattern:
Assistant
Let me see the test around that line.
Assistant
Now let me understand the full picture and plan the fix. Let me re-read the key functions:
Assistant
Now let me look at the full
process_v_bind_on_elementfunction:Assistant
Let me check the
quoted_js_stringfunction:Assistant
Let me look at the
quoted_js_stringfunction:Assistant
Let me also check
escape_html_attr:Assistant
Let me check
escape_html_attr:Assistant
Let me check the imports in plain.rs:
Assistant
Let me check what's in the parent module and what's imported:
Assistant
Let me check the mod.rs file:
Assistant
Let me check the parent codegen module:
Assistant
Let me check the element module structure:
Assistant
Let me check
has_dynamic_bind:Assistant
Let me check how
cstr!works:Assistant
Let me look at the cstr macro to understand its syntax:
Assistant
Let me check the
expression_to_stringmethod:Assistant
Let me look at the
expression_to_stringimplementation:Assistant
Let me check what's available in the props module:
Assistant
Now I have a full understanding of the code. Let me implement the fix. First, let me edit
process_element_attrsto skip staticstylewhenv-showis present:Assistant
Let me use the proper edit syntax:
Assistant
Let me try the edit command using the currently open file:
Assistant
Now let me edit
process_v_bind_on_elementto merge v-show into:style:Assistant
Let me check the area around the edit more carefully:
Assistant
I see there's an extra
}on line 406. Let me fix that by removing it:Assistant
I see there are now duplicate lines. Let me fix them:
Assistant
Good, the structure looks correct now. Now let me edit
process_v_show_on_element:Assistant
Let me see the current state of the function:
Assistant
Now let me edit
process_v_show_on_element:Assistant
Let me try to build and see if the changes compile:
Assistant
Let me run all the SSR tests:
Assistant
All tests pass. Now let me create a quick reproduction test to verify the fix works:
Assistant
Let me use a simpler approach - I'll temporarily add a test that prints output:
Assistant
Let me find the test function and temporarily add a debug output to verify the fix:
Assistant
Let me create a temporary test file to verify the fix:
Assistant
Let me run the temporary test:
Assistant
The static style case output is correct! The JavaScript conditional ensures only one
styleattribute is rendered. Let me update the test to correctly validate:Assistant
Let me run the updated test:
Assistant
The fix works correctly for all three cases. Let me clean up the temporary test file and run all tests one final time:
Assistant
Let me clean up temporary files and run all tests one final time:
Assistant
All 108 tests pass. Let me verify the changes with git diff:
Assistant
The changes look correct. Let me verify the final state with a quick sanity check:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.