@@ -429,24 +429,23 @@ pub const HTMLCollection = struct {
429429 return null ;
430430 }
431431
432- pub fn postAttach (self : * HTMLCollection , js_this : JsThis ) ! void {
433- const len = try self .get_length ();
434- for (0.. len ) | i | {
435- const node = try self .item (@intCast (i )) orelse unreachable ;
436- const e = @as (* parser .Element , @ptrCast (node ));
437- const as_interface = try Element .toInterface (e );
438- try js_this .setIndex (@intCast (i ), as_interface , .{});
439-
440- if (try item_name (e )) | name | {
441- // Even though an entry might have an empty id, the spec says
442- // that namedItem("") should always return null
443- if (name .len > 0 ) {
444- // Named fields should not be enumerable (it is defined with
445- // the LegacyUnenumerableNamedProperties flag.)
446- try js_this .set (name , as_interface , .{ .DONT_ENUM = true });
447- }
448- }
432+ pub fn indexed_get (self : * HTMLCollection , index : u32 , has_value : * bool ) ! ? Union {
433+ return (try _item (self , index )) orelse {
434+ has_value .* = false ;
435+ return undefined ;
436+ };
437+ }
438+
439+ pub fn named_get (self : * const HTMLCollection , name : []const u8 , has_value : * bool ) ! ? Union {
440+ // Even though an entry might have an empty id, the spec says
441+ // that namedItem("") should always return null
442+ if (name .len == 0 ) {
443+ return null ;
449444 }
445+ return (try _namedItem (self , name )) orelse {
446+ has_value .* = false ;
447+ return undefined ;
448+ };
450449 }
451450};
452451
0 commit comments