Skip to content
TheChatArchiveThe Chat Archive
fable-5· unknownHugging Face ibragim-bad/swe_rebench_07_2026_trajectories

fix(atelierssr): v-show on a non-root element with an existing style attr/:style binding…

  1. User

    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.

  2. Assistant

    Let me look at the helper functions in the crate root and check existing tests for v-show.

  3. Assistant

    Now I'll make the fix. Three coordinated edits in plain.rs:

    1. Skip the static style attribute when v-show will merge it:

  4. Assistant

    2. Merge v-show into the :style binding's _ssrRenderStyle call:

  5. Assistant

    The module aliases vize_carton::String (a CompactString). Use that:

  6. Assistant

    All three outputs emit exactly one style attribute with display: none merged last. This matches Vue's shape. Accepting and running the full suite:

  7. Assistant

    That failure looks unrelated (CLI template-syntax quirks). Let me confirm it's pre-existing by stashing my changes:

  8. Assistant

    Clean. The fix is complete.

    Summary

    Problem: process_v_show_on_element (the non-fallthrough-root path) always appended a standalone style="display: none;" chunk, so elements that already had a static style attr or a :style binding got two style attributes — the HTML parser keeps the first, dropping display:none (or the bound style).

    Changes in crates/vize_atelier_ssr/src/codegen/element/plain.rs:

    1. process_element_attrs (plain.rs:108-114) — a static style attribute is now also skipped when the element carries a v-show with an expression, since it gets merged into the single style emission instead.

    2. process_v_bind_on_element, Some("style") branch (plain.rs:388-411) — the _ssrRenderStyle call now folds in the v-show term as the last array entry: _ssrRenderStyle([static?, bound, (expr) ? null : { display: "none" }]), so display:none wins in the merge.

    3. process_v_show_on_element (plain.rs:513-549) — now actually uses its element param:

      • defers entirely when a :style binding exists (edit 2 handles it);
      • merges with a static style attr into one attribute: style="${_ssrRenderStyle(["color:red", (expr) ? null : { display: "none" }])}", matching Vue's ssrTransformElement shape;
      • keeps the original standalone chunk when there's no other style source (existing snapshots unchanged).

    Tests: added three snapshot tests (v_show_merges_static_style, v_show_merges_style_binding, v_show_merges_static_and_dynamic_style) — each now emits exactly one style attribute. All 111 SSR crate tests pass; the one workspace failure (build_respects_configured_template_syntax_quirks) is pre-existing on the clean tree and unrelated.

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