Lightpanda: the headless browser designed for AI and automation
webapi: document.head matches by local name; getElementsByName is HTML-only
Francis Bouvier867fd9bc2ef6
diff --git a/src/browser/webapi/HTMLDocument.zig b/src/browser/webapi/HTMLDocument.zigindex f3223fee6..0fdeeedc7 100644--- a/src/browser/webapi/HTMLDocument.zig+++ b/src/browser/webapi/HTMLDocument.zig@@ -44,14 +44,17 @@ pub fn asEventTarget(self: *HTMLDocument) *@import("EventTarget.zig") {}// HTML-specific accessors-pub fn getHead(self: *HTMLDocument) ?*Element.Html.Head {+// The head is the first html-namespace child of the document element whose+// local name is head, whatever its Zig element type (e.g. a createElementNS+// "blah:head" is an HTMLUnknownElement but still qualifies).+pub fn getHead(self: *HTMLDocument) ?*Element {const doc_el = self._proto.getDocumentElement() orelse return null;var child = doc_el.asNode().firstChild();- while (child) |node| {- if (node.is(Element.Html.Head)) |head| {- return head;+ while (child) |node| : (child = node.nextSibling()) {+ const el = node.is(Element) orelse continue;+ if (el._namespace == .html and std.mem.eql(u8, el.getLocalName(), "head")) {+ return el;}- child = node.nextSibling();}return null;}diff --git a/src/browser/webapi/collections/node_live.zig b/src/browser/webapi/collections/node_live.zigindex 79b4bf87f..800e5dc60 100644--- a/src/browser/webapi/collections/node_live.zig+++ b/src/browser/webapi/collections/node_live.zig@@ -283,6 +283,8 @@ pub fn NodeLive(comptime mode: Mode) type {},.name => {const el = node.is(Element) orelse return false;+ // getElementsByName only considers HTML elements.+ if (el._namespace != .html) return false;const name_attr = el.getAttributeSafe(comptime .wrap("name")) orelse return false;return std.mem.eql(u8, name_attr, self._filter);},