From cb23ad7cbb98d7e00df61c5d9c2fc9eb7f159761 Mon Sep 17 00:00:00 2001 From: Francis Bouvier Date: Sun, 12 Jul 2026 16:00:42 +0200 Subject: [PATCH] webapi: moveBefore fires connectedCallback without a disconnectedCallback Fixes the failing subtest of WPT /dom/nodes/moveBefore/custom-element-move-reactions.html (5/6 -> 6/6): when a moved custom element defines no connectedMoveCallback, the fallback is disconnectedCallback + connectedCallback - and either may be undefined. The error from invoking the missing disconnectedCallback returned early and skipped connectedCallback entirely. Both fallback invocations now tolerate a missing method and let the other one run. Coverage: /dom/nodes/moveBefore/custom-element-move-reactions.html 5/6 -> 6/6 (fully green). Co-Authored-By: Claude Fable 5 --- src/browser/webapi/element/html/Custom.zig | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/browser/webapi/element/html/Custom.zig b/src/browser/webapi/element/html/Custom.zig index 8880195c2..a74bcd9da 100644 --- a/src/browser/webapi/element/html/Custom.zig +++ b/src/browser/webapi/element/html/Custom.zig @@ -225,10 +225,11 @@ fn invokeCallbackOnElement(element: *Element, comptime callback_name: [:0]const // for "move", we call "connectedMoveCallback" if it exists, else we fallback // to "disconnectedCallback" + "connectedCallback" if (js_element.has("connectedMoveCallback")) { - js_element.callMethod(void, "connectedMoveCallback", .{}) catch return; + js_element.callMethod(void, "connectedMoveCallback", .{}) catch {}; } else { - js_element.callMethod(void, "disconnectedCallback", .{}) catch return; - js_element.callMethod(void, "connectedCallback", .{}) catch return; + // Either callback may be undefined; the other still runs. + js_element.callMethod(void, "disconnectedCallback", .{}) catch {}; + js_element.callMethod(void, "connectedCallback", .{}) catch {}; } }