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
Now let's write the fix.
Assistant
Good,
ExpressionNodeis already available viasuper::*glob import. Now let's build.Assistant
Now let's write a reproduce script to check the output.
Assistant
Let's create a temp test file using the crate's own test infra to check output.
Assistant
Let's simplify: precompute the dynamic style exp once before the loop, and use it uniformly in both emit call sites.
Assistant
All 108 tests pass. Now let's run the full workspace test suite to be safe, and check clippy warnings for unused param etc.
Assistant
Good, the whole workspace builds fine. Now let's view the final diff.
Assistant
All edge cases behave correctly. Clean up example files.
Assistant
Now let's run the full test suite once more, including other crates that might use SSR codegen (e.g., snapshot tests elsewhere, vize_test_runner).
Assistant
Confirmed: pre-existing failure unrelated to my changes. Good - my change doesn't affect this. Let's run remaining full workspace tests excluding this known-failing test to double check everything else passes.
Assistant
Only the pre-existing unrelated failure remains. Let's double check git diff and clean state.
Assistant
Good, only the intended file is modified. Let's do a final review of the diff.
Assistant
The change looks solid. Let's do a final check on clippy for this file specifically to catch style issues.
Assistant
Let's rewrite
emit_merged_show_styleusingvize_carton::String,cstr!, andappend!/appends!.Assistant
No clippy warnings now. Let's re-run the tests to confirm everything still passes.
Assistant
All good. Let's do the reproduce check once more with the cleaned-up code.
Assistant
Confirmed fix works and the repository is clean aside from the intended fix.
Now, going through the checklist:
Assistant
Checklist review
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.