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
vue<template> <div class="wrapper"> <span style="color:red" v-show="ok">x</span> </div> </template>Actual
js<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 static attr or binding and merge into a single style binding, reusing the merge logic already present in the single-root path (, plain.rs:245-254). Assistant
Let me start by exploring the repository structure and understanding the codebase, then look at the specific file mentioned in the issue.
Assistant
Now let me look at the props module and related helpers to understand how the single-root path merges style entries.
Assistant
Let me explore the codegen structure and how v-show is transformed, plus the tests directory.
Assistant
Let me look at the snapshot tests for v-show and the process flow. Let me check how the single-root path handles v-show and how
process_element_attrsworks with v-show ordering.Assistant
Let me reproduce the issue first by writing a quick test compile. Let me check how to compile a test template.
Assistant
Let me write a quick reproduction test to see the current behavior.
Assistant
Let me add a temporary test in the test file to reproduce via cargo test, which is the cleanest approach.
Assistant
I've reproduced the issue. The problem is clear:
<span style="color:red" v-show="ok">→ two style attributes<span v-show="ok" :style="{ color }">→ two style attributes (display:none first, then style binding dropped by parser)<span style="color:red" v-show="ok" :style="{ color }">→ two style attributes
Now let me understand how Vue's SSR handles this. Vue rewrites v-show into a single style binding. Let me look at how
process_element_attrsiterates and howprocess_v_bind_on_elementfor style already merges static+dynamic. The fix should makeprocess_v_show_on_elementmerge with existing style (static + :style).Let me look at how the props are ordered and how the iteration handles things. The key insight: v-show needs to merge into the style attribute. Let me look at the
process_element_attrsflow more carefully and how v-show interacts.Assistant
No Vue source available. Let me understand how the single-root path (
build_element_attrs_expression) handles v-show and look at the resulting snapshots for the component case to understand the expected output.Assistant
Let me check if there's a vendored Vue compiler source or reference snapshots in the repo to match the exact expected output.
Assistant
Assistant
Now let me look at the lib.rs imports and the
get_v_show_exphelper, plus howprocess_v_bind_on_elementstyle branch andprocess_v_show_on_elementare structured.Assistant
Now let me check what's imported in plain.rs's
super::*and confirmget_v_show_exp/has_v_showavailability.Assistant
Let me check the
expression_to_stringsignature and the type ofexp, plus theStringtype used.Assistant
Now I have a clear understanding. Let me view the exact lines to edit.
Assistant
Now let me make the edits. First,
process_element_attrs:Assistant
There's a duplicate "/// Process element attributes" comment line. Let me fix that.
Assistant
Let me simplify the condition to avoid the redundant
has_v_showcheck with the let-chain (clippy cleanliness).Assistant
Now let me edit the
:stylebranch inprocess_v_bind_on_elementto merge v-show:Assistant
The edit broke the class branch closing. Let me view the current state and fix it.
Assistant
I need to fix the class branch closing (missing lines) and remove the extra
}. Let me fix the class branch first:Assistant
Now remove the extra
}at line 437:Assistant
Now let me edit
process_v_show_on_elementto suppress emission when there's an existing style:Assistant
There are leftover duplicate lines 553-556. Let me remove them:
Assistant
Now let me build and run the reproduction test:
Assistant
Build succeeded. Now let me run the reproduction test:
Assistant
All cases now produce a single
styleattribute. Let me remove the temporary test and run the existing test suite:Assistant
All tests pass. Let me run clippy to ensure no lint warnings (the crate has clippy configured):
Assistant
No clippy warnings. Let me check for any downstream snapshots/tests in other crates that might be affected by SSR v-show output changes:
Assistant
These are mostly lint rules and other independent compilers (dom, vapor). Let me run the SFC tests and the e2e-related canon tests which may compose SSR output:
Assistant
Let me check if these SFC failures are caused by my change or pre-existing. Let me investigate one failure:
Assistant
These failures are environmental (
failed to start pkl server: No such file or directory), not related to my change. Let me confirm by stashing my change and re-running:Assistant
Confirmed: the SFC failures are pre-existing environmental issues (missing pkl binary), unrelated to my change. Let me run the
vize_canontests which may exercise SSR compilation end-to-end:Assistant
All pass. Let me run a few more edge cases (reversed prop ordering, root-level, v-show with no exp, class+style+v-show) to be thorough:
Assistant
All edge cases produce a single
styleattribute. The root-level (single-root) path is unchanged. Let me remove the temporary test and run the full SSR suite once more:Assistant
All tests pass. Let me verify the temporary test modules are fully removed and review my final diff:
Assistant
The diff is clean and minimal. Let me do a final build verification and confirm no stray temp files in the repo:
Assistant
Only the intended file is modified, and the build is clean. Let me run the complete SSR test suite one final time to confirm everything passes:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.