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 the specific file mentioned in the issue.
Assistant
Let me look at the specific file mentioned in the issue.
Assistant
Let me view the file with line numbers to understand the exact locations.
Assistant
Let me view the key sections -
collect_element_directive_attrandprocess_v_show_on_element.Assistant
Let me look at the props module and helpers to understand how the single-root path merges entries.
Assistant
Let me explore the SSR crate structure to understand the transform pipeline.
Assistant
Let me look at the transforms.rs to understand how SSR directive transforms work.
Assistant
Let me look at the codegen.rs to understand the string part pushing mechanism.
Assistant
Let me look at the
expression_to_stringanddynamic_arg_to_stringmethods, and the helpers module.Assistant
Let me look at
expression_to_stringanddynamic_arg_to_stringin component.rs.Assistant
Now let me look at the existing tests to understand the test infrastructure.
Assistant
Let me find the snapshot files and look at relevant ones for v-show.
Assistant
Let me look at the existing v-show snapshots to understand the expected output format.
Assistant
Let me look at the dynamic_class_and_style snapshot to understand the existing
:styleoutput format for plain elements.Assistant
Let me look at the lib.rs for the public API and how to compile.
Assistant
Now let me create a reproduction script to confirm the issue.
Assistant
Let me build the SSR crate first to ensure it compiles, then run my reproduction.
Assistant
I've reproduced the issue. Let me check all callers of
process_directive_on_elementandprocess_v_show_on_elementto understand the scope.Assistant
Let me view the exact sections I need to modify with line numbers.
Assistant
Let me check how
merge_prop_valuesand other props functions are used across the codebase.Assistant
I've confirmed the bug. Now let me implement the fix. First, let me modify
process_element_attrsto pre-scan forv-showand suppress the standalonestyle/:styleemissions when v-show will merge them.Assistant
Now let me view and modify
process_v_show_on_element.Assistant
Let me verify the written content is correct.
Assistant
The edits look correct. Let me build and run the reproduction.
Assistant
The fix works — all cases now produce exactly one
styleattribute. Let me test more edge cases including root elements (inherit_attrs path), void elements, and ordering variants.Assistant
Let me check the root path's ordering more carefully and compare with Vue's official expectations. Let me search for any Vue compiler-ssr reference tests.
Assistant
Vue isn't installed. Let me check if pnpm dependencies can be installed, or look at the tests directory for reference Vue test cases.
Actually, let me check the
tests/directory at the repo root — it might have reference Vue compiler-ssr test outputs.Assistant
No SSR-specific reference fixtures. Let me look at the v-show.pkl in vdom to see if there's a
:style+ v-show case, and what the expected output is. These are vdom (not ssr) fixtures though.Let me check the v-show.pkl fixtures for style+show combos.
Assistant
My fix produces exactly the format described in the issue's "Expected" section:
style=[existing, expr ? null : {display:'none'}]— existing first, show last, exactly onestyleattribute. Let me run the existing SSR test suite to ensure nothing breaks.Assistant
All 68 tests pass. Let me run clippy to ensure no lint issues with my changes.
Assistant
Clippy passes cleanly. Let me verify the no-v-show
:style+ static case is unchanged (regression check) and test a few more complex expressions.Assistant
Excellent! All cases work correctly, and no-v-show cases are unchanged (regression check passes). Let me check if any integration tests across the workspace use the SSR compiler.
Assistant
Let me build the dependent crates to ensure nothing breaks downstream.
Assistant
Let me run tests for the dependent crates that exercise SSR codegen.
Assistant
The 8 failures are environmental ("failed to start pkl server: No such file or directory") — the
pkltool isn't installed. Let me confirm these are pre-existing by stashing my changes and re-running.Assistant
Confirmed — those 8 failures are pre-existing environmental issues (missing
pkltool), unrelated to my change. Let me verify thepkltool situation and check pass-count parity to be thorough.Assistant
Identical pass counts (470 passed, 8 pre-existing pkl failures) with and without my changes — no regressions. Let me run the vitrine tests too, then clean up my temporary example file.
Assistant
Now let me clean up the temporary example file I created for reproduction.
Assistant
Let me review the final diff to ensure it's clean and correct.
Assistant
The diff is clean. Let me run the SSR test suite and clippy one final time to confirm everything passes.
Assistant
All tests pass and clippy is clean. Let me do a final end-to-end verification with the exact reproduction from the issue, then clean up.
Assistant
The fix is confirmed end-to-end — both issue reproductions now produce exactly one
styleattribute in the expected format[existing, expr ? null : {display:'none'}]. Let me clean up the temporary file.Assistant
The change is clean — only
plain.rsis modified and the temporary example is removed. Let me do a final review of the complete modified sections.Assistant
Everything looks correct. Let me do a final build to confirm the code compiles cleanly.
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.