From ffdc1a71574461ef610978463dca8e75661dfc98 Mon Sep 17 00:00:00 2001 From: Francis Bouvier Date: Fri, 10 Jul 2026 22:32:11 +0200 Subject: [PATCH] webapi: only HTML-namespace elements are named by their name attribute Fixes the failing subtest "hasOwnProperty, getOwnPropertyDescriptor, getOwnPropertyNames" in WPT /dom/nodes/Document-getElementsByTagName.html (17/18 -> 18/18) and /dom/nodes/Element-getElementsByTagName.html (18/19 -> 19/19). Per the DOM spec's supported property names for HTMLCollection, the name attribute only exposes elements in the HTML namespace (ids expose any element). The live-collection getByName fallback matched any element with a name attribute; it now skips non-HTML elements, matching the enumerator which already had the guard. Coverage: Document-getElementsByTagName.html 17/18 -> 18/18, Element-getElementsByTagName.html 18/19 -> 19/19. /dom/collections stays fully green. Co-Authored-By: Claude Fable 5 --- src/browser/webapi/collections/node_live.zig | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/browser/webapi/collections/node_live.zig b/src/browser/webapi/collections/node_live.zig index ab96ed661..82769cd07 100644 --- a/src/browser/webapi/collections/node_live.zig +++ b/src/browser/webapi/collections/node_live.zig @@ -194,6 +194,11 @@ pub fn NodeLive(comptime mode: Mode) type { // (like length or getAtIndex) var tw = self._tw.clone(); while (self.nextTw(&tw)) |element| { + // Per spec, only HTML-namespace elements are exposed via + // their name attribute (ids expose any element). + if (element._namespace != .html) { + continue; + } const element_name = element.getAttributeSafe(comptime .wrap("name")) orelse continue; if (std.mem.eql(u8, element_name, name)) { return element;