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).Interface
Assistant
I'll start by exploring the repository structure and then examining the specific file mentioned in the issue.
Assistant
I need to focus on running one command at a time rather than trying to parallelize.
Assistant
Now let me look at the
process_v_show_on_elementfunction mentioned in the issue, around line 479-493:Assistant
Now let me understand how
process_v_show_on_elementis called and how the element attrs are processed. Let me look at the rest of the file and find where it's called:Assistant
Now let me look at the
process_directive_on_elementand the area around line 327 whereprocess_v_show_on_elementis called:Assistant
Now I understand the flow. Let me look at the helper functions
has_dynamic_bind,get_element_attr_value, etc. Let me also look at the propsmodule:Assistant
Let me find the
has_dynamic_bindhelper function:Assistant
Let me check what tests exist and how they're run:
Assistant
Let me look for existing v-show test snapshots to understand the current expected output:
Assistant
Let me check the v_show test definition and look at the ssr helper implementations:
Assistant
I'm checking how
has_v_showgets imported and used in the codegen by looking at the imports in plain.rs.Assistant
Let me check how the
SsrRenderStyleandSsrRenderClasshelpers are used and defined, and look atuse_ssr_helper:Assistant
Now let me write a reproduction script. First, let me check how
compile_ssris used and the lib's public API:Assistant
Now let me create a reproduction test to confirm the bug:
Assistant
Let me run the reproduction by adding it as a temporary example. First let me check the package structure:
Assistant
I've reproduced the bug. The output clearly shows duplicate
styleattributes in all cases with existing style. Now let me check whether the tests run in strict snapshot mode:Assistant
I need to check the existing v-show snapshots to see how my changes affect them, and I can update them since they're test outputs rather than test logic.
Assistant
I've confirmed the bug. Now let me implement the fix. I'll modify
process_v_show_on_elementto own the style emission and merge with existing static/dynamic style, and add the corresponding skip conditions. Let me start withprocess_element_attrsto also skip a staticstylewhen v-show is present:Assistant
Now let me update
process_element_attrsto also skip a staticstylewhenv-showis present (since v-show will own the style emission):Assistant
Now let me update
process_v_bind_on_elementto skip emitting:stylewhenv-showis present (v-show will own it):Assistant
Now let me rewrite
process_v_show_on_elementto own the style emission and merge with existing static/dynamic style:Assistant
Now let me run the reproduction script to verify the fix:
Assistant
The fix works — now there's a single
styleattribute in all cases. Let me search the entire repo for v-show snapshots and tests that might be affected:Assistant
The snapshot diffs show exactly the intended fix (single
styleattribute via_ssrRenderStyle). These are test output snapshots that legitimately need updating. Let me check the lib.rs snapshot test and the component snapshots (which use the already-correct path):Assistant
Both failing snapshots show exactly the intended fix. The lib test (root-level v-show using the inherit_attrs path) and component tests pass. Now let me update the two changed snapshot files. Let me review the new
.newsnapshots:Assistant
Now let me update the snapshot files:
Assistant
All SSR tests pass. Now let me check whether there are broader tests (e2e/integration) that exercise SSR v-show output, since the issue mentions e2e fixtures:
Assistant
Let me check how the e2e test runner works and whether it exercises SSR:
Assistant
Let me check if any e2e test cases actually enable
ssr: true:Assistant
No e2e SSR v-show cases. Let me clean up my temporary example and verify there are no clippy warningsintroduced:
Assistant
No clippy warnings. Let me run clippy with tests and verify the full test suite once more, then do a final verification of the reproduction:
Assistant
No warnings. Let me create a final verification script (temporary, will remove before submit) to confirm the exact issue scenario is fixed:
Assistant
The fix works perfectly for both issue scenarios. Let me clean up the temporary example:
Assistant
Let me review the complete diff of the source change:
Assistant
The diff is clean and well-documented. Let me run the complete test suite once more to confirm everything passes:
Assistant
Let me verify no other crates in the workspace depend on this SSR codegen in a way that could have snapshots affected:
Assistant
Let me check if the SFC crate uses SSR and has snapshots that could be affected:
Assistant
Let me check if this SFC test compiles with SSR enabled (which could be affected by my change):
Assistant
That test uses default (non-SSR) compilation, so it's unaffected. Let me run the SFC and vitrine tests to be sure nothing is broken:
Assistant
Let me verify whether these SFC failures are pre-existing (unrelated to my change) by stashing and re-running:
Assistant
The SFC failures are pre-existing (identical 8 failures on the clean baseline without my changes). Let me confirm one of them is unrelated to v-show/SSR:
Assistant
These SFC snapshot failures are pre-existing (present on the clean baseline without my changes) and are in SFC compile snapshots, not SSR — unrelated to my fix. Let me verify the build-snapshot tests (which compile real projects) aren't affected by my SSR change either:
Assistant
No SSR build snapshots exist, confirming my change is isolated. Let me do a final confirmation that the reproduction case is fixed and review the final state of the modified function:
Assistant
The implementation is complete and correct. Let me run the SSR test suite one final time to confirm the green state:
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.