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
Let me explore the repository structure and the relevant files.
Assistant
Now I see the
collect_element_directive_attrfor "show" case at line ~249-254. But it uses{exp}but doesn't actually substitute — wait, it usescstr!with{exp}placeholder. Let me check the cstr macro behavior. Actually the issue says this is the reference. Let me look atprocess_v_show_on_elementaround line 479-493.Assistant
Let me look at the broader structure of the file to understand how elements are processed and how style attributes are handled.
Assistant
Now let me look at
process_directive_on_elementand how it dispatches toprocess_v_show_on_element.Assistant
Let me look at
normalize_prop_entries,component_prop_entry, and the props module.Assistant
Let me look at existing tests to understand the expected output format.
Assistant
Let me look at the snapshots for v-show tests and the existing
v_show_with_other_attrssnapshot which hasid="foo" v-show="bar"— there's no style there, so the standalone form is fine.Let me look at the snapshot files.
Assistant
Let me look at the test helpers and the v-show test module.
Assistant
Let me reproduce the bug by writing a temporary test.
Assistant
Confirmed the bug. Now let me look at the transforms module for v-show helpers and the
_ssrRenderStylehelper.Assistant
Let me check the
cstr!macro definition andquoted_js_stringusage.Assistant
Let me check how
plain.rsreferences the transform helpers (e.g.crate::get_v_html_exp).Assistant
Now let me look at the exact current code for
process_element_attrsto edit it.Assistant
Now let me edit
process_element_attrsto skip static style and:stylebind when v-show is present.Assistant
Now let me rewrite
process_v_show_on_elementto merge into a single style binding when existing style is present.Assistant
Now let me rewrite
process_v_show_on_element.Assistant
The heredoc escaping got mangled. Let me use the
edittool instead. Let me open the file at the relevant line.Assistant
Now let me edit the function using the
edittool.Assistant
Let me check if
ExpressionNodeis already imported at module level to avoid duplicate import errors.Assistant
ExpressionNodeis already in scope viasuper::*(used elsewhere without local import). Let me revert my addeduseto justPropNodeto avoid a potential duplicate import.Assistant
Now let me build and run the repro test.
Assistant
All cases now produce exactly one
styleattribute. Let me run the full existing test suite to check for regressions.Assistant
All 68 existing tests pass. Let me also verify the root-level (inherit_attrs) and component paths produce single style attributes.
Assistant
The root and component paths already produce single
stylekeys. Let me run a clippy/check to ensure no warnings/errors, then clean up temp files.Assistant
Build succeeds. Let me run clippy on the crate to catch any warnings.
Assistant
The only warning is from my temp test file, which I'll remove now. No warnings from the source changes.
Assistant
Let me run the full test suite once more to confirm everything passes after cleanup.
Assistant
Let me also check whether any other crates depend on this and run their tests to ensure no regressions.
Assistant
The 8 failures are environmental (
pkl server: No such file or directory— a missing tool, unrelated to my change). 470 passed. Let me confirm these fail independently of my change by checking the error is purely about the missingpklbinary (it loads fixtures). Let me verify vize_vitrine results.Assistant
Let me confirm the SFC failures are pre-existing (unrelated to my change) by stashing and re-running one.
Assistant
Confirmed — the SFC failures are pre-existing (environmental, missing
pklbinary) and unrelated to my change.Let me review the final diff.
Assistant
The fix is complete and verified. Let me provide the checklist reasoning before submitting.
Checklist:
-
Reproduced the error: ✅ Confirmed via a temporary test that
<span style="color:red" v-show="ok">x</span>emitted<span style="color:red" style="display: none;">x</span>(twostyleattributes), and the:stylecases likewise emitted duplicates. -
Confirmed fix resolves the error: ✅ After the fix, all cases emit exactly one
styleattribute rendered via_ssrRenderStyle([...])merging the existing style sources with(expr ? null : { display: "none" }). The standalone form is preserved when there is no existing style (sodisplay:nonestill applies correctly). -
Edge cases considered: ✅ Handled static + v-show, + v-show (both source orders), static + + v-show combined, and v-show alone. Also verified the root/inherit_attrs path (/) and component path already merge correctly and remain unchanged. v-show's expression is appended last so wins, matching Vue's .
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.