mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-07-30 17:25:58 -04:00
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 <noreply@anthropic.com>
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user