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
No new interfaces are introduced.
ADDITIONAL ADVICE
Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use
git checkout <file>to restore the file to its original state. You can also reset all changes in the repository usinggit reset --hardcommand. Additionally, you can usegit stashandgit stash popto temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you callsubmit) usinggit statusorgit diffcommands. However you don't need to usegit addorgit commitbefore submitting your changes. In fact,submitonly submits currently unstaged changes because it usesgit diffto get the changes that need to be submitted.CHECKLIST
Before submitting your solution, please go over the following checklist and make sure you've done everything:
- If an error was reported in the issue description, I have successfully reproduced it.
- If an error was reported in the issue description, I have confirmed that my fix resolves the error.
- I have thought about edge cases and made sure my fix handles them as well.
- I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. I want you to list every bullet from this checklist and write your reasoning for why you think you did it or didn't need to.
Repository has been uploaded and your shell is currently at the repository root. Time to solve the issue!
(Current directory: /vize, current file: none) bash-$
Assistant
Good,
ExpressionNodeandPropNodealready available viasuper::*. Now let's implement the changes.Assistant
Now let's check the
process_v_show_on_elementfunction andRuntimeHelperimport to ensureSsrRenderStyleis in scope, and build.Assistant
Builds fine. Now let's check
process_v_show_on_elementstill works for the no-existing-style case, and check for unused_elparam warning etc.Assistant
No warnings shown (grep found nothing, exit code 1 is just grep's "no match"). Now let's write a quick reproduction script using the crate's test infra to verify actual output.
Assistant
Existing tests exist. Let's look at them.
Assistant
These don't have style attrs, so should remain unchanged. Now let's write a temp reproduction test.
Assistant
Now let's write a quick temp test file to check reproduction cases using cargo test as a script (without modifying existing test files).
Assistant
This all works as expected. Now clean up the example file and run the existing test suite.
Assistant
All existing tests pass. Let's also run the broader workspace tests related to SSR/vitrine to make sure nothing else depends on old behavior.
Assistant
That's fine, only ssr crate relevant. Let's run full workspace build to be safe.
Assistant
Full workspace builds. Now let's view the final diff for review.
Assistant
That's fine, unrelated. Let's check clippy for warnings in our modified file.
Assistant
Let's just build the joined array string manually to avoid
.jointype issues, usingmerge_prop_values-like style building.Assistant
Now let's rerun clippy to confirm no more disallowed-type/macro warnings.
Assistant
No warnings. Now let's re-run the reproduction example and the full test suite again.
Assistant
Same expected results, still correct after refactor. Clean up example file and rerun full test suite.
Assistant
All 68 + 40 tests pass. Let's build workspace once more to be sure nothing else broke, and view final diff.
Assistant
Both changes intact, workspace builds successfully. Let's view the final diff for a full review.
Assistant
Good, consistent CompactString usage everywhere. Now let's also double check
push_string_part_static("\"")etc — already used same pattern elsewhere. Let's run full test suite once more and remove leftover repro files.Assistant
Everything is clean. Now let's go through the checklist.
Assistant
Checklist review:
-
Reproduced the reported error: Yes — I wrote a temporary example (
repro_vshow.rs, removed before submitting) reproducing<span style="color:red" v-show="ok">and<span :style="{...}" v-show="ok">, confirming the original code emitted two separatestyle="..."chunks (one static, one fromprocess_v_show_on_element's unconditional" style=\"display: none;\""string), which is exactly the duplicate-attribute bug described in the issue. -
Confirmed the fix resolves the error: Yes — after the fix, the same reproduction cases now emit a single
style="${_ssrRenderStyle([...])}"chunk that merges the existing static style and/or:stylebinding together with the v-showdisplay:nonetoggle via_ssrRenderStyle, matching Vue'sssrTransformShowbehavior and producing exactly onestyleattribute. -
Thought about edge cases: Yes — handled: (1) v-show with no existing style at all (kept the original lightweight standalone-toggle behavior, verified via
basic_v_show/v_show_with_other_attrstests still passing), (2) v-show + static style only, (3) v-show +:stylebinding only, (4) v-show + both static style and:stylebinding simultaneously, (5) v-show directive appearing before vs. after the style attribute/binding in source order (merge point is resolved deterministically regardless of order), and (6) elements withclassbindings unaffected (existing class-merge logic untouched). -
Ran existing tests: Yes —
cargo test -p vize_atelier_ssr(108 tests across unit + snapshot suites) all pass, andcargo build --workspacesucceeds with no compile errors. Also rancargo clippy -p vize_atelier_ssr --all-targetsand fixed the disallowed-type/macro warnings it flagged (switched to project conventions:CompactString/cstr!/append!instead ofstd::String/format!), leaving zero warnings.
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Identical first prompt
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.5-35B-A3BCompare side by side →
Qwen/Qwen3.5-35B-A3BCompare side by side →