Lightpanda: the headless browser designed for AI and automation
webapi: HTMLCollection named properties are not enumerable in for-in
Francis Bouvierd357f093c0a0
diff --git a/src/browser/webapi/collections/HTMLCollection.zig b/src/browser/webapi/collections/HTMLCollection.zigindex 83f0224c5..36d2b5443 100644--- a/src/browser/webapi/collections/HTMLCollection.zig+++ b/src/browser/webapi/collections/HTMLCollection.zig@@ -180,7 +180,23 @@ pub const JsApi = struct {return self.getByName(name, frame) orelse error.NotHandled;}- }.wrap, null, deleteByName, getNames, null, defineByName, describeByName, .{ .null_as_undefined = true });+ }.wrap, null, deleteByName, getNames, queryByName, defineByName, describeByName, .{ .null_as_undefined = true });++ // Named properties are [LegacyUnenumerableNamedProperties]: the query+ // reports them non-enumerable, so for-in skips them while+ // Object.getOwnPropertyNames still lists them via the enumerator.+ // Deliberately NOT ReadOnly: v8 consults the query when a [[Set]] walks+ // the prototype chain, and a read-only property on the prototype would+ // block the expando that the spec's ignore-named-props rule requires+ // (HTMLCollection-as-prototype.html). Writability as seen by+ // getOwnPropertyDescriptor comes from describeByName, and direct+ // assignments still fail through defineByName.+ fn queryByName(self: *HTMLCollection, name: []const u8, frame: *Frame) !u32 {+ if (name.len > 0 and self.getByName(name, frame) != null) {+ return js.v8.DontEnum;+ }+ return error.NotHandled;+ }// HTMLCollection has no indexed setter: per Web IDL, assigning to or// defining any array index property fails (TypeError in strict mode).