Skip to content
TheChatArchiveThe Chat Archive
MiniMaxminimax/minimax-m3· unknownHugging 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).

    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 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. MiniMax Assistant

    Let me start by exploring the repository structure to understand what we're working with.

  3. MiniMax Assistant

    Let me check how process_v_show_on_element is called and find where process_element_attrs and collect_element_directive_attr are used.

  4. MiniMax Assistant

    Let me find existing tests for v-show and understand current behavior:

  5. MiniMax Assistant

    Let me look at existing snapshots:

  6. MiniMax Assistant

    Let me check Vue's reference implementation:

  7. MiniMax Assistant

    Let me look at the runtime helpers (especially ssrRenderStyle):

  8. MiniMax Assistant

    Let me also look at get_dynamic_bind_exp:

  9. MiniMax Assistant

    Let me reproduce the issue first:

  10. MiniMax Assistant

    Now I understand the issue. Let me also look at process_element_attrs more carefully and decide on the fix:

  11. MiniMax Assistant

    Let me look at the context struct to see what's available:

  12. MiniMax Assistant

    Let me look at Vue's compiler-ssr tests for v-show to confirm the expected output format:

  13. MiniMax Assistant

    Let me look at ssrRenderStyle to understand its signature:

  14. MiniMax Assistant

    Vue's runtime ssrRenderStyle accepts either an object, an array of strings/objects, or a string. So _ssrRenderStyle([staticStyle, expr ? null : {display:'none'}]) is valid.

    Now let me also check what _mergeProps does with the style prop when merging — looking at the components_with_v_show_merges_style snapshot, we see:

    _mergeProps({ style: ["color: red;", ((_ctx.ok) ? null : { display: "none" })] }, _attrs)
    

    This uses _mergeProps. Looking at Vue's _mergeProps, when there's a style prop, it's an array [staticStyle, dynamicStyle, ...]. Then when applied to a DOM element, the array form is normalized via normalizeStyle.

    For SSR, we need to also normalize the style array. Let me check whether _ssrRenderStyle handles arrays...

    Looking at Vue 3 source: _ssrRenderStyle does:

    function ssrRenderStyle(raw) {
      if (raw == null) return ''
      if (isString(raw)) return normalizeStyle(raw)
      // support nested objects/array
      // ...
    }
    

    Actually it's more like:

    const s = isString(raw) ? raw : isArray(raw) ? raw.map(s => isString(s) ? s : normalizeStyle(s)).join(';') : normalizeStyle(raw)
    

    Hmm, I think it normalizes each entry. Let me also consider using _normalizeStyle explicitly if needed.

    Looking at the existing snapshot for component case, the style is passed as an array directly:

    _mergeProps({ style: ["color: red;", ((_ctx.ok) ? null : { display: "none" })] }, _attrs)
    

    And _mergeProps will handle the array. When the component receives style=[...], it normalizes.

    For SSR HTML element with style attribute, calling _ssrRenderStyle([staticStyle, dynamicObj]) should work — Vue's ssrRenderStyle accepts arrays.

    OK let me proceed with the implementation. Let me also think about other edge cases:

    1. What if attr.value is None? E.g., <span style v-show="ok"> — that's an empty value style attribute. Looking at the existing code, if attr.value is None, it just emits style (no value). For my fix, I'd want to handle this case too — just treat it as empty string.

    Actually wait, looking at the code:

    self.push_string_part_static(" ");
    self.push_string_part_static(&attr.name);
    if let Some(value) = &attr.value {
        self.push_string_part_static("=\"");
        self.push_string_part_static(&escape_html_attr(&value.content));
        self.push_string_part_static("\"");
    }
    

    So a valueless attribute like <span style> gets emitted as style (no ="..."). HTML5 actually treats valueless style as style="". Let me check what Vue does for this... Actually, for now I'll just handle the case where value is Some, and skip (continue with rest of attribute processing) if it's None — to keep my fix minimal.

    Actually, let me also handle: a valueless style attribute is rare and unusual. I'll handle it: if there's no value, just treat it as empty string for the merge.

    Hmm, let me think about another edge case: <span v-show="ok" style> (valueless style). The current behavior would emit style${((_ctx.ok) ? "" : " style=\"display: none;\"")} which is a bug. With my fix, since has_style_attr_or_binding is true, the standalone chunk is skipped, and we try to merge v-show into the style. But the style attr has no value.

    Actually let me trace through:

    • v-show comes first (dir.name == "show"), check has_style_attr_or_binding — true (style attr exists). Skip standalone chunk.
    • style attr (no value). attr.name == "style" matches, &attr.value is None... Hmm we go to the if attr.name == "style" && let Some(value) = &attr.value && let Some(v_show) = &v_show_exp check, which checks let Some(value) = ... — that fails. So we fall through to the regular attribute handling. Emit style. Bug remains.

    Actually wait, if attr.value is None and attr.name == "style", my code should still emit style="display: none" merged in for v-show. Let me handle this case:

    if attr.name == "style"
        && let Some(v_show) = &v_show_exp
    {
        let static_style = attr.value.as_ref()
            .map(|v| quoted_js_string(&v.content))
            .unwrap_or_else(|| "\"\"".to_compact_string());
        self.use_ssr_helper(RuntimeHelper::SsrRenderStyle);
        let show_cond = cstr!("(({v_show}) ? null : {{ display: \"none\" }})");
        self.push_string_part_static(" style=\"");
        self.push_string_part_dynamic(&cstr!("_ssrRenderStyle([{static_style}, {show_cond}])"));
        self.push_string_part_static("\"");
        continue;
    }
    

    But wait, this would interfere with has_dynamic_style logic — the existing code skips static style if :style is present. Let me preserve that:

    if attr.name == "style" && has_dynamic_style {
        continue; // existing logic
    }
    
    if attr.name == "style"
        && let Some(v_show) = &v_show_exp
    {
        // merge v-show into static style
        let static_style = ...;
        ... merged chunk ...
        continue;
    }
    
    // regular static attribute handling
    ... existing logic ...
    

    Hmm actually the existing logic has:

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

    I want to keep that. Then if attr is style but dynamic style is NOT present, AND we have v-show, we merge. Otherwise we emit as-is.

    Let me restructure more clearly:

    fn process_element_attrs(&mut self, el: &ElementNode) {
        use vize_atelier_core::ast::PropNode;
    
        let has_dynamic_class = self.has_dynamic_bind(el, "class");
        let has_dynamic_style = self.has_dynamic_bind(el, "style");
        
        // Find v-show expression (if any). Capture once.
        let v_show_exp: Option<String> = el.props.iter().find_map(|prop| {
            let PropNode::Directive(dir) = prop else { return None; };
            if dir.name != "show" { return None; }
            dir.exp.as_ref().map(|exp| self.expression_to_string(exp))
        });
        
        // Has a style attr or :style binding? Then we'll merge v-show into it,
        // suppressing the standalone chunk.
        let has_style_attr = el.props.iter().any(|prop| matches!(prop, PropNode::Attribute(attr) if attr.name == "style"));
        let has_style_both = has_style_attr || has_dynamic_style;
    
        for prop in &el.props {
            match prop {
                PropNode::Attribute(attr) => {
                    if (attr.name == "class" && has_dynamic_class)
                        || (attr.name == "style" && has_dynamic_style)
                    {
                        continue;
                    }
                    
                    if attr.name == "style"
                        && let Some(v_show) = &v_show_exp
                    {
                        // Merge v-show into static style emission
                        self.use_ssr_helper(RuntimeHelper::SsrRenderStyle);
                        let static_style = attr.value
                            .as_ref()
                            .map(|v| quoted_js_string(&v.content))
                            .unwrap_or_else(|| "\"\"".to_compact_string());
                        let show_cond = cstr!("(({v_show}) ? null : {{ display: \"none\" }})");
                        self.push_string_part_static(" style=\"");
                        self.push_string_part_dynamic(&cstr!("_ssrRenderStyle([{static_style}, {show_cond}])"));
                        self.push_string_part_static("\"");
                        continue;
                    }
                    
                    self.push_string_part_static(" ");
                    self.push_string_part_static(&attr.name);
                    if let Some(value) = &attr.value {
                        self.push_string_part_static("=\"");
                        self.push_string_part_static(&escape_html_attr(&value.content));
                        self.push_string_part_static("\"");
                    }
                }
                PropNode::Directive(dir) => {
                    if dir.name == "bind"
                        && let Some(ExpressionNode::Simple(arg)) = &dir.arg
                        && arg.is_static
                        && arg.content == "style"
                        && let Some(v_show) = &v_show_exp
                        && let Some(style_exp_node) = &dir.exp
                    {
                        self.use_ssr_helper(RuntimeHelper::SsrRenderStyle);
                        let style_exp_str = self.expression_to_string(style_exp_node);
                        let show_cond = cstr!("(({v_show}) ? null : {{ display: \"none\" }})");
                        self.push_string_part_static(" style=\"");
                        self.push_string_part_dynamic(&cstr!("_ssrRenderStyle([{style_exp_str}, {show_cond}])"));
                        self.push_string_part_static("\"");
                        continue;
                    }
                    
                    if dir.name == "show" {
                        // Only emit the standalone style chunk if there's no existing
                        // style attr/binding to merge with (already merged above).
                        if !has_style_both
                            && let Some(v_show) = &v_show_exp
                        {
                            self.push_string_part_dynamic(&cstr!(
                                "(({v_show}) ? \"\" : \" style=\\\"display: none;\\\"\")"
                            ));
                        }
                        continue;
                    }
                    
                    self.process_directive_on_element(el, dir);
                }
            }
        }
    }
    

    Wait, there's a problem with let Some(ExpressionNode::Simple(arg)) = &dir.arg. The let inside if let is not quite right syntax. Let me think... Actually, in Rust you can chain if let with && using let chains, which requires Rust 2024 edition or feature flag. Let me check the Rust edition:

  15. MiniMax Assistant

    Rust edition 2024 supports let chains in if let. So if cond && let Some(x) = y && let Some(z) = w syntax should work. Let me check for examples in the codebase:

  16. MiniMax Assistant

    OK Rust 2024 supports let chains. Let me look at some examples to see the syntax in use:

  17. MiniMax Assistant

    Let me check the type signatures:

  18. MiniMax Assistant

    OK so dir.arg is Option<ExpressionNode>. Now let me also check how ExpressionNode is defined and how we can check for Simple with is_static:

  19. MiniMax Assistant

    Let me check has_dynamic_bind and the quoted_js_string function:

  20. MiniMax Assistant

    Now I have everything I need. Let me write the fix.

    Let me also confirm that has_dynamic_bind takes &self (and not &mut self):

  21. MiniMax Assistant

    Good, has_dynamic_bind takes &self. Now let me write the fix. Let me also re-check that we import ExpressionNode already:

  22. MiniMax Assistant

    Now let me apply the fix. Let me edit the file:

  23. MiniMax Assistant

    Now I have enough context. Let me apply the fix:

  24. MiniMax Assistant

    Let me also remove the now-unused process_v_show_on_element method and clean up process_directive_on_element:

  25. MiniMax Assistant

    Now let me remove the "show" arm of process_directive_on_element and the process_v_show_on_element function. Since we intercept v-show in process_element_attrs directly now, those are dead code.

    Actually, wait. Let me think about whether process_directive_on_element is called anywhere ELSE besides process_element_attrs. If not, then removing the show arm is safe.

    Let me check:

  26. MiniMax Assistant

    process_directive_on_element is only called from one place: in process_element_attrs's PropNode::Directive(dir) arm. Now that we intercept v-show in that arm before calling process_directive_on_element, it's safe to remove the show arm and the process_v_show_on_element function.

  27. MiniMax Assistant

    Now let me find and remove process_v_show_on_element (now dead code):

  28. MiniMax Assistant

    I see there's a stray } at line 558. Let me fix this:

  29. MiniMax Assistant

    Let me add a blank line for readability:

  30. MiniMax Assistant

    I accidentally removed the closing brace. Let me fix it:

  31. MiniMax Assistant

    My edits have gotten messy. Let me reset and apply the changes more carefully:

  32. MiniMax Assistant

    Good, file is back to original. Now let me apply the fix again, more carefully:

  33. MiniMax Assistant

    Good. Now let me also remove process_v_show_on_element (dead code) and empty out the "show" arm of process_directive_on_element:

  34. MiniMax Assistant

    Now let me remove the process_v_show_on_element function:

  35. MiniMax Assistant

    There's still a stray } on line 562. Let me remove it:

  36. MiniMax Assistant

    I have a missing closing brace at line 560 for process_v_model_on_element. Let me add it:

  37. MiniMax Assistant

    The indentation of process_custom_directive looks off by 4 spaces. Let me look more carefully:

  38. MiniMax Assistant

    Let me try to compile now and see if there are any errors:

  39. MiniMax Assistant

    Let me carefully look at the structure now:

  40. MiniMax Assistant

    The structure is broken. Let me reset and try again more carefully:

  41. MiniMax Assistant

    Now let me apply changes more carefully. First, just replace process_element_attrs:

  42. MiniMax Assistant

    Now let me try compiling to confirm this part works:

  43. MiniMax Assistant

    It compiles. Now let me also remove the process_v_show_on_element function (since it's now dead code) and replace the "show" arm in process_directive_on_element:

  44. MiniMax Assistant

    This "show" => at line 328 is for collect_element_directive_attr (the inherit_attrs/component path which correctly merges). I shouldn't change that. Let me only update line 409 (in process_directive_on_element) and remove process_v_show_on_element:

  45. MiniMax Assistant

    Now let me remove the dead-code process_v_show_on_element function:

  46. MiniMax Assistant

    I made a mess again. Let me reset the file and apply changes carefully:

  47. MiniMax Assistant

    Let me apply changes step-by-step. First, replace process_element_attrs:

  48. MiniMax Assistant

    Let me verify the fix works with my repro test before cleaning up the dead code:

  49. MiniMax Assistant

    The fix works correctly. Let me clean up the dead code (process_v_show_on_element) and update process_directive_on_element:

  50. MiniMax Assistant

    Now let me remove the dead process_v_show_on_element:

  51. MiniMax Assistant

    Now let me compile and run all tests:

  52. MiniMax Assistant

    Let me also confirm the existing snapshots haven't changed:

  53. MiniMax Assistant

    All tests pass. Let me re-confirm the repro test outputs show the fix correctly:

  54. MiniMax Assistant

    Let me test more edge cases:

  55. MiniMax Assistant

    All edge cases work correctly. Let me run the full test suite:

  56. MiniMax Assistant

    All 68 tests pass. Let me also test the broader workspace:

  57. MiniMax Assistant

    There's a test failure but it doesn't look related to my change. Let me check if it was failing before my changes:

  58. MiniMax Assistant

    The test was failing before my changes (pre-existing). My changes don't break anything. Let me also run vize_test_runner:

  59. MiniMax Assistant

    Let me now check what tests exist in vize_test_runner and check v-show related tests:

  60. MiniMax Assistant

    The fix is complete. Let me clean up the reproduction test file:

  61. MiniMax Assistant

    Good, only the plain.rs file is modified. Let me look at the final diff:

  62. MiniMax Assistant

    The diff is clean and minimal. Let me run all SSR tests one more time to confirm:

  63. MiniMax Assistant

    All tests pass. Let me check that the existing snapshots are unchanged:

  64. MiniMax Assistant

    No changes to existing snapshots. Let me do a final review of the change:

  65. MiniMax Assistant

    The fix looks clean. Let me also do a final test where I create a quick repro script to confirm:

  66. MiniMax Assistant

    The fix resolves the bug described in the issue. Let me now do the final submit:

    Summary of changes

    The issue was that process_v_show_on_element in crates/vize_atelier_ssr/src/codegen/element/plain.rs:479-493 emitted a standalone style="display: none;" chunk after the element attributes, creating duplicate style attributes when the element already had a static style attribute or a :style binding. The HTML parser keeps the first and drops subsequent ones, so v-show failed to hide the element.

    Checklist review:

    • Reproduced the error: I created a reproduction script that confirmed the duplicate style attribute bug for all the cases mentioned in the issue (static style="color:red" v-show="ok", v-show="ok" :style="style", v-show="ok" :style="{ color }").

    • Confirmed the fix resolves the error: After my fix, the output contains exactly one style="..." attribute with the merged expression _ssrRenderStyle(["color:red", ((_ctx.ok) ? null : { display: "none" })]) — when ok===false, this renders color:red;display:none (hidden); when ok===true, it renders color:red (visible). This matches Vue's SSR ssrTransformShow output for components which already correctly merged v-show into the style prop via _mergeProps.

    • Considered edge cases: I tested many scenarios including:

      • :style binding + v-show (any order)
      • Static style attribute + v-show
      • Valueless style attribute + v-show (treats as empty string)
      • Both static style and :style + v-show (dynamic wins, static skipped via existing has_dynamic_style logic)
      • Mixed attribute ordering (id + v-show + style, :style + v-show + class, etc.)
      • v-show with no style attr/binding (legacy standalone chunk preserved)
      • v-show with no expression (no output)
      • v-show on a constant false expression (works with constant folding)
    • Existing tests pass: All 68 vize_atelier_ssr tests pass and no existing snapshots were modified.

    The fix in process_element_attrs:

    1. Pre-computes v_show_exp (the v-show expression string, if any) and has_style_emission (whether the element has any form of style).
    2. For static style attr with v-show: emits _ssrRenderStyle([staticStyle, (expr ? null : {display:'none'})]) instead of the static style.
    3. For :style directive (v-bind:style) with v-show: emits the merged _ssrRenderStyle([styleExp, (expr ? null : {display:'none'})]) instead of letting process_v_bind_on_element handle it.
    4. For v-show directive: only emits the legacy ((expr) ? "" : " style=\"display: none;\"") chunk when there's no existing style attr/binding (since otherwise the v-show was merged above).
    5. Removes the now-dead process_v_show_on_element function and updates the "show" arm in process_directive_on_element to a no-op (since the inline logic in process_element_attrs is the sole handler now).

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