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

    Now add tests for the new merge cases:

  3. Assistant

    Good — get_compiled_string wraps in a div, so the inner element goes through the non-fallthrough path. Build and run:

  4. Assistant

    The new output is exactly the expected merged form. The 3 failures are just new snapshots pending acceptance. Let me accept and inspect them:

  5. Assistant

    All merged correctly. Now run the full crate test suite to check for regressions:

  6. Assistant

    Fixed. All 111 crate tests pass, clippy and fmt are clean.

    Changes

    crates/vize_atelier_ssr/src/codegen/element/plain.rs

    1. process_v_show_on_element (the buggy element-level path) — now inspects the element for an existing static style attribute (get_element_attr_value) and/or a :style binding (get_dynamic_bind_exp). When either exists, it emits a single merged style attribute — style="${_ssrRenderStyle([<static>, <bound>, (expr ? null : { display: "none" })])}" — matching Vue's ssrTransformShow semantics. When neither exists, the original conditional standalone-attr output is preserved (so the two existing v-show snapshots are byte-identical).

    2. process_element_attrs — skips standalone emission of the static style attribute when v-show is present (same pattern already used for the dynamic-style skip), since v-show now owns the merged emission.

    3. process_v_bind_on_element (Some("style") branch) — returns early when the element has v-show, deferring style emission to the v-show handler so only one style attribute is ever produced.

    New snapshot tests (tests/ssr_snapshot.rs)

    • static style + v-show → style="${_ssrRenderStyle(["color:red", ((_ctx.ok) ? null : { display: "none" })])}"
    • :style binding + v-show → style="${_ssrRenderStyle([{ color: _ctx.color }, ...])}"
    • static + bound + v-show → all three sources merged into one attribute

    Each case now renders exactly one style attribute, so display: none is no longer dropped by the browser's first-attribute-wins parsing.

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