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
Let me start by exploring the repository structure to understand what we're working with.
Assistant
Let me explore the vize_atelier_ssr crate, particularly the file mentioned in the issue.
Assistant
Now let me explore how the SSR
stylerendering works and look at related test cases.Assistant
Let me look at the existing tests for v-show in the SSR crate.
Assistant
Let me look at the test file to understand the format.
Assistant
Let me look at the imports and structure of the file more carefully.
Assistant
Let me create a reproduce script first to confirm the issue.
Assistant
Let me create a temporary reproduction test file.
Assistant
The bug is reproduced. Now let me look at the
quoted_js_stringhelper and understand more.Assistant
Now I understand the bug. Let me implement the fix. First, let me understand the data structures better.
Assistant
Now I'll implement the fix. Let me look at the exact lines I need to modify.
Assistant
Now let me apply the fix step by step.
Step 1: Add a
has_v_showhelper and modifyprocess_element_attrsto skip static style when v-show is present.Assistant
Step 2: Now let me modify
process_v_bind_on_elementto skip:stylewhen v-show is present.Assistant
The edit didn't go well. Let me view the affected section to understand the damage:
Assistant
Let me revert the file and start over:
Assistant
Now let me start over with a careful approach. First, let me check the current state of the file:
Assistant
Let me re-apply changes carefully one at a time. First, the
process_element_attrs:Assistant
Now I can see the file. Let me use
editinstead:Assistant
Now let me look at the
:stylecase in process_v_bind_on_element:Assistant
Now let me look at
process_v_show_on_element:Assistant
I see an extra closing brace. Let me fix it:
Assistant
Now let me verify the fix with the reproduction test:
Assistant
The fix works. Now let me run all existing tests to ensure nothing is broken:
Assistant
Let me verify a few more edge cases:
Assistant
Let me also verify the component (root) case isn't affected by my changes:
Assistant
The test failure was due to a faulty assertion. The actual output is correct (it has the escaped quotes). Let me verify with a corrected assertion:
Assistant
Excellent! All edge cases pass. Let me run all the existing tests one more time to confirm:
Assistant
Let me look at the current state of my changes to verify everything is correct:
Assistant
Let me view the entire modified
process_v_show_on_elementfunction to make sure it's correct:Assistant
Let me also view the other changes:
Assistant
Let me check if there are other places that process v-show:
Assistant
There's an existing
has_v_showfunction in transforms.rs. Let me look at it - I can potentially use it instead of defining my own.Looking at the import in
element.rs:use super::{SsrCodegenContext, helpers::escape_html_attr, helpers::extract_destructure_params};And:
use vize_carton::cstr;So I could potentially import
has_v_showfrom the parent module. Let me check the lib.rs:Assistant
Good -
has_v_showis exported aspub. Let me update my code to use that instead of redefining it.Actually wait, it's exposed as
crate::has_v_show, not withincodegen. Let me check howget_v_show_expis used in element.rs:Assistant
Let me clean things up. I have two options:
- Use
crate::has_v_show(already exported). - Keep my local
has_v_show_elementhelper.
Option 1 is cleaner since it uses the existing function. Let me refactor.
Wait, let me also check
get_v_show_expandget_v_model_expusages:- Use
Assistant
Let me refactor to use the existing
crate::has_v_show:Assistant
Let me simplify by removing the helper and inlining
crate::has_v_show(el):Assistant
The file got broken again. Let me revert and try a different approach:
Assistant
Let me try a different approach using sed to apply changes more reliably:
Assistant
All 8 reproduction tests pass. Let me run all existing tests:
Assistant
All 68 existing tests still pass. Let me also check the broader test suite to make sure I haven't broken anything in related crates:
Assistant
Now let me view the final state of my changes:
Assistant
Let me also check related tests in the broader repo:
Assistant
These don't appear related. Let me also check that we have unit tests for the patterns at the higher level tests:
Assistant
Let me verify my changes don't break this test project:
Assistant
Let me also double-check no relevant test was missed:
Assistant
Let me now look at the diff to confirm my changes:
Assistant
Let me clean up the temporary reproduction file before submitting:
Assistant
Now let me run the existing tests one more time to make sure everything still works:
Assistant
All 68 tests pass. Let me also run a wider scope of tests to ensure I haven't broken anything else:
Assistant
The entire workspace builds. Let me also run clippy to ensure no lints:
Assistant
Clippy passes. Let me also do one more test by creating a quick reproduction test in a temporary location to verify the fix:
Assistant
Let me clean up the temporary test files:
Assistant
Let me also run the tests one final time to ensure everything is in order:
Assistant
All 68 tests pass. Let me view the final modified function to confirm everything is in order:
Assistant
The fix looks good. Now let me also verify the file size hasn't unexpectedly ballooned:
Assistant
Let me run all the existing tests one final time to ensure everything is working:
Assistant
All tests pass. Let me now also verify the diff is exactly what I expect:
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 →
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 →