Skip to content
TheChatArchiveThe Chat Archive
DeepSeekdeepseek/deepseek-v4-pro· deepseekHugging Face ibragim-bad/swe_rebench_07_2026_trajectories

ISSUE DESCRIPTION fix(atelierssr): v-show on a non-root element with an existing style…

  1. 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_element unconditionally appends a standalone style="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 standalone style="display: none;" chunk instead of merging v-show into the element's existing style. When the element already has a static style attribute or a :style binding, the generated HTML contains TWO style attributes. The HTML parser keeps the FIRST, so display:none is dropped and v-show fails to hide the element (or, in the :style case, the display:none chunk 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 ssrTransformShow rewrites v-show into the single style binding (style=[existing, expr ? null : {display:'none'}]) so there is exactly one style attribute.

    Suggested direction

    In process_v_show_on_element (plain.rs:479-493), inspect the element for an existing static style attr or :style binding 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).

    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 using git reset --hard command. Additionally, you can use git stash and git stash pop to temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you call submit) using git status or git diff commands. However you don't need to use git add or git commit before submitting your changes. In fact, submit only submits currently unstaged changes because it uses git diff to 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-$

  2. DeepSeek Assistant

    Let me start by understanding the repository structure and the issue. The issue is about v-show on a non-root element with an existing style attribute or :style binding emitting a duplicate style attribute. Let me first explore the relevant files.

    Let me look at the file structure and the specific file mentioned in the issue.

  3. DeepSeek Assistant

    Let me look at the specific file mentioned in the issue.

  4. DeepSeek Assistant

    Now let me look at the plain.rs file, focusing on the two key sections mentioned in the issue.

  5. DeepSeek Assistant

    Let me use a different approach.

  6. DeepSeek Assistant

    Now let me look at the collect_element_directive_attr function around lines 245-254.

  7. DeepSeek Assistant

    Let me look at how process_v_show_on_element is called and the broader context.

  8. DeepSeek Assistant

    Let me look at lines around 327 and 150 to understand the two code paths.

  9. DeepSeek Assistant

    Let me do one command at a time.

  10. DeepSeek Assistant

    Now let me look at the lines around 327 to see how process_v_show_on_element is called.

  11. DeepSeek Assistant

    Let me see how process_directive_on_element and collect_element_directive_attr are called.

  12. DeepSeek Assistant

    Let me look at lines around 100-170 to understand the two paths

  13. DeepSeek Assistant

    Let me look at process_v_bind_on_element to understand how dynamic style is

  14. DeepSeek Assistant

    Let me look at the process_v_bind_on_element function.

  15. DeepSeek Assistant

    Let me see the full process_element_attrs and understand the attribute

  16. DeepSeek Assistant

    Let me see these helper

  17. DeepSeek Assistant

    Let me also check how has_dynamic_bind could be adapted for v-show. Let me also look at the full file to understand the structure better

  18. DeepSeek Assistant

    Now I have a comprehensive understanding of the issue. Let me create a reproduction script first, then implement the fix

  19. DeepSeek Assistant

    Let me look at the existing SSR tests to understand the codebase better

  20. DeepSeek Assistant

    Let me find the v-show tests and snapshots

  21. DeepSeek Assistant

    Let me look at the v-show test snapshots to see current behavior

  22. DeepSeek Assistant

    Let me also see the other v-show snapshot and the component v-show snapshots

  23. DeepSeek Assistant

    Now let me look at the component v-show snapshots to see the correct behavior (the component path uses the correct merge approach):

  24. DeepSeek Assistant

    One at a time.

  25. DeepSeek Assistant

    Now let me see the component_with_v_show_merges_style snapshot, where merging is the correct reference

  26. DeepSeek Assistant

    Let me look at the imports and beginning of the file

  27. DeepSeek Assistant

    Let me now look at the entire process_v_show_on_element function and the surrounding context to plan my changes. Let me also look at the has_dynamic_bind function to model my has_v_show after it.

    Now let me implement the fix. Here's my plan:

    1. Add a has_v_show helper method that checks if the element has a v-show directive.
    2. In process_element_attrs, also skip static style when has_v_show is true.
    3. In process_v_bind_on_element for style, check if v-show is also present. If so, merge the v-show expression into the style expression.
    4. In process_v_show_on_element, if there's no :style binding, emit the merged style (static + v-show). If there's :style, do nothing (already handled by step 3).

    Let me implement this now.

    Actually, let me reconsider step 3. The issue is that process_v_bind_on_element doesn't have access to the v-show expression. It would need to extract it from the element's directives. Let me think about how to handle this.

    Actually, let me simplify the approach. Instead of modifying process_v_bind_on_element, I can:

    1. Add has_v_show helper.
    2. In process_element_attrs, skip static style when has_dynamic_style || has_v_show.
    3. In process_v_show_on_element:
      • Get the static style value (if any, it was skipped so it hasn't been emitted).
      • Get the dynamic style expression (if any).
      • Get the v-show expression.
      • Emit a single merged style using _ssrRenderStyle.
      • IMPORTANT: If there's a :style binding, we should also skip it in process_v_bind_on_element or handle it here.

    Wait, but process_v_bind_on_element will still emit its own style when it encounters the :style directive. We need to prevent that.

    Hmm, let me think about this differently. The simplest and most correct approach:

    Modify process_v_show_on_element to:

    1. Check if there's a static style attribute. Get its value.
    2. Check if there's a :style binding. Get its expression.
    3. Emit a merged style using _ssrRenderStyle that incorporates all three (static, dynamic, v-show).
    4. Since process_element_attrs already skips static style when there's a dynamic style binding, we need to also skip it when there's v-show. We do this in process_element_attrs.
    5. For the :style case: we need to prevent process_v_bind_on_element from emitting style when v-show is also present.

    For step 5, the simplest approach: In process_v_bind_on_element for the "style" arm, check if v-show is present. If so, skip (don't emit anything), because process_v_show_on_element will handle it.

    But wait, there's a complication: what if :style comes before v-show in the props order? Then process_v_bind_on_element runs first and we need it to skip. And then process_v_show_on_element runs later and emits the merged style.

    What if v-show comes before :style? Then process_v_show_on_element runs first and emits the merged style. Then process_v_bind_on_element runs and would emit another style attribute. We'd need it to skip.

    So in process_v_bind_on_element for "style", if has_v_show, skip. And in process_v_show_on_element, always emit the merged style.

    This is clean. Let me implement it now.

    Let me write out the changes:

    1. Add has_v_show method (modeled after has_dynamic_bind):
    fn has_v_show(&self, el: &ElementNode) -> bool {
        el.props.iter().any(|prop| {
            let PropNode::Directive(dir) = prop else {
                return false;
            };
            dir.name == "show"
        })
    }
    
    1. In process_element_attrs: Change:
    let has_dynamic_class = self.has_dynamic_bind(el, "class");
    let has_dynamic_style = self.has_dynamic_bind(el, "style");
    

    To:

    let has_dynamic_class = self.has_dynamic_bind(el, "class");
    let has_dynamic_style = self.has_dynamic_bind(el, "style");
    let has_v_show = self.has_v_show(el);
    

    And change the condition:

    if (attr.name == "class" && has_dynamic_class)
        || (attr.name == "style" && has_dynamic_style)
    {
        continue;
    }
    

    To:

    if (attr.name == "class" && has_dynamic_class)
        || (attr.name == "style" && (has_dynamic_style || has_v_show))
    {
        continue;
    }
    
    1. In process_v_bind_on_element for "style": Add a check: if has_v_show, skip and return.

    2. In process_v_show_on_element:

    fn process_v_show_on_element(
        &mut self,
        el: &ElementNode,
        dir: &vize_atelier_core::ast::DirectiveNode,
    ) {
        let exp = match &dir.exp {
            Some(exp) => self.expression_to_string(exp),
            None => return,
        };
    
        let has_dynamic_style = self.has_dynamic_bind(el, "style");
        let static_style = self.get_element_attr_value(el, "style");
        let dynamic_style_exp = self.get_dynamic_bind_exp(el, "style");
        
        self.use_ssr_helper(RuntimeHelper::SsrRenderStyle);
        self.push_string_part_static(" style=\"");
        
        let show_exp = cstr!("(({exp}) ? null : {{ display: \"none\" }})");
        
        let style_exp = if let Some(ref static_s) = static_style {
            let quoted = quoted_js_string(static_s);
            if let Some(ref dyn_style) = dynamic_style_exp {
                cstr!("_ssrRenderStyle([{quoted}, {dyn_style}, {show_exp}])")
            } else {
                cstr!("_ssrRenderStyle([{quoted}, {show_exp}])")
            }
        } else if let Some(ref dyn_style) = dynamic_style_exp {
            cstr!("_ssrRenderStyle([{dyn_style}, {show_exp}])")
        } else {
            cstr!("_ssrRenderStyle({show_exp})")
        };
        
        self.push_string_part_dynamic(&style_exp);
        self.push_string_part_static("\"");
    }
    

    Wait, I need to check what cstr! macro does. Let me look at itLet me look at how cstr! and quoted_js_string are defined

  28. DeepSeek Assistant

    Let me search more

  29. DeepSeek Assistant

    Let me see the cstr macro

  30. DeepSeek Assistant

    Now let me check quoted_js_string:

  31. DeepSeek Assistant

    Let me look at the available RuntimeHelper variants for SSR

  32. DeepSeek Assistant

    Now let me look at the overall structure of process_v_show_on_element more closely and check the entire file to understand the full flow.

    Let me now implement the fix. Here's my refined plan:

    1. Add has_v_show method - checks if element has a v-show directive
    2. Modify process_element_attrs - skip static style when has_v_show is true
    3. Modify process_v_bind_on_element for "style" arm - if has_v_show, skip and return
    4. Modify process_v_show_on_element - emit merged style using _ssrRenderStyle

    Let me now make the edits. First, let me see the exact lines I need to modify.

  33. DeepSeek Assistant

    Now let me look at the :style handling in process_v_bind_on_element:

  34. DeepSeek Assistant

    Now I have a clear picture. Let me implement the fix step by step.

    Step 1: Add has_v_show helper method after has_dynamic_bind.

  35. DeepSeek Assistant

    Now let me add the has_v_show helper method after has_dynamic_bind

  36. DeepSeek Assistant

    I see that the edit replaced has_dynamic_bind with has_v_show. Let me fix this by looking at the current state

  37. DeepSeek Assistant

    The function has_dynamic_bind is missing its closing }. Let me fix this

  38. DeepSeek Assistant

    There's a duplicate line. Let me fix it:

  39. DeepSeek Assistant

    Good, the helper functions look correct. Now let me modify process_element_attrs to skip static style when has_v_show is true:

  40. DeepSeek Assistant

    Now let me make the changes to process_element_attrs

  41. DeepSeek Assistant

    I see the issue - has_dynamic_style was removed. Let me fix this

  42. DeepSeek Assistant

    Now update line 114 to include has_v_show in the condition for static style

  43. DeepSeek Assistant

    Now let me look at the :style handling in process_v_bind_on_element and skip it when v-show is

  44. DeepSeek Assistant

    Now let me modify the "style" arm in process_v_bind_on_element to skip when v-show is present

  45. DeepSeek Assistant

    There's an extra } at line 397. Let me remove it

  46. DeepSeek Assistant

    Now let me modify process_v_show_on_element to emit a

  47. DeepSeek Assistant

    Now let me replace the process_v_show_on_element function with the merged style approach

  48. DeepSeek Assistant

    There's a missing blank line between process_v_show_on_element and process_custom_directive. Let me fix that.

  49. DeepSeek Assistant

    Let me insert a blank line before the doc comment on line

  50. DeepSeek Assistant

    Now let me try to build the project to check for compilation

  51. DeepSeek Assistant

    There's an extra } at the end. Let me fix this

  52. DeepSeek Assistant

    Let me remove the extra } on line 592

  53. DeepSeek Assistant

    Now let me try to

  54. DeepSeek Assistant

    The build succeeded. Now let me run the SSR

  55. DeepSeek Assistant

    Looking at the test failures, I see the new output always emits style="" even when v-show is true. For the simple case (no existing style), the original conditional approach was fine. Let me refine the fix to only merge when there IS an existing style

  56. DeepSeek Assistant

    Now let me build and run the tests

  57. DeepSeek Assistant

    All 68 tests pass. Let me also run a broader test to make sure nothing else is broken

  58. DeepSeek Assistant

    All tests pass. Let me review the final diff to make sure everything is correct

  59. DeepSeek Assistant

    The diff looks correct. Let me now verify the fix by running a quick test to see the output for the problematic case from the issue

  60. DeepSeek Assistant

    Let me check the snapshot for the basic v-show test to confirm the output

  61. DeepSeek Assistant

    All tests pass. Let me verify the component tests are unaffected (since we only touched the element path

  62. DeepSeek Assistant

    All tests pass. Let me now run the full test suite for the vize_atelier_ssr crate one more time to confirm

  63. DeepSeek Assistant

    All tests pass. Let me verify the final state of the changes by looking at the complete diff once more

  64. DeepSeek Assistant

    Now let me go through the checklist:

    1. Reproduce the error: The issue describes that v-show on a non-root element with an existing style attribute or :style binding emits a duplicate style attribute. Looking at the original code in process_v_show_on_element, it unconditionally emits style="display: none;" as a standalone chunk, which would indeed produce two style attributes when combined with an existing static style or :style binding.

    2. Confirm fix resolves the error: My fix:

    • Skips the static style attribute in process_element_attrs when v-show is present
    • Skips :style emission in process_v_bind_on_element when v-show is present (letting process_v_show_on_element handle the merge)
    • In process_v_show_on_element, when there IS an existing static/dynamic style, merges all three into a single style attribute using _ssrRenderStyle
    • When there's NO existing style, uses the original simple conditional approach (no regression)

    3. Edge cases considered:

    • v-show alone (no style) → original simple approach, no regression
    • style="color:red" v-show="ok" → single merged style attribute
    • :style="{ color }" v-show="ok" → single merged style attribute
    • style="color:red" :style="{ bg }" v-show="ok" → all three merged into one
    • Static style without v-show → unaffected
    • :style without v-show → unaffected
    • Component path (uses _mergeProps) → unaffected

    4. Tests: All 108 tests (40 + 68) pass, including all v-show, component, and element tests.

    The fix is clean, minimal, and correct. Let me submit.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.