File tree Expand file tree Collapse file tree 2 files changed +13
-6
lines changed Expand file tree Collapse file tree 2 files changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -128,10 +128,10 @@ pub const Element = struct {
128128
129129 // append children to the node
130130 const ln = try parser .nodeListLength (children );
131- var i : u32 = 0 ;
132- while ( i < ln ) {
133- defer i += 1 ;
134- const child = try parser .nodeListItem (children , i ) orelse continue ;
131+ for (0 .. ln ) | _ | {
132+ // always index 0, because ndoeAppendChild moves the node out of
133+ // the nodeList and into the new tree
134+ const child = try parser .nodeListItem (children , 0 ) orelse continue ;
135135 _ = try parser .nodeAppendChild (node , child );
136136 }
137137 }
@@ -662,4 +662,10 @@ test "Browser.DOM.Element" {
662662 .{ "a1.after('over 9000', a1_a);" , "undefined" },
663663 .{ "after_container.innerHTML" , "<div></div>over 9000<p></p>" },
664664 }, .{});
665+
666+ try runner .testCases (&.{
667+ .{ "var div1 = document.createElement('div');" , null },
668+ .{ "div1.innerHTML = \" <link/><table></table><a href='/a'>a</a><input type='checkbox'/>\" " , null },
669+ .{ "div1.getElementsByTagName('a').length" , "1" },
670+ }, .{});
665671}
Original file line number Diff line number Diff line change @@ -432,15 +432,16 @@ pub const HTMLCollection = struct {
432432 for (0.. len ) | i | {
433433 const node = try self .item (@intCast (i )) orelse unreachable ;
434434 const e = @as (* parser .Element , @ptrCast (node ));
435- try js_this .setIndex (@intCast (i ), e , .{});
435+ const as_interface = try Element .toInterface (e );
436+ try js_this .setIndex (@intCast (i ), as_interface , .{});
436437
437438 if (try item_name (e )) | name | {
438439 // Even though an entry might have an empty id, the spec says
439440 // that namedItem("") should always return null
440441 if (name .len > 0 ) {
441442 // Named fields should not be enumerable (it is defined with
442443 // the LegacyUnenumerableNamedProperties flag.)
443- try js_this .set (name , e , .{ .DONT_ENUM = true });
444+ try js_this .set (name , as_interface , .{ .DONT_ENUM = true });
444445 }
445446 }
446447 }
You can’t perform that action at this time.
0 commit comments