@@ -22,6 +22,7 @@ const Page = @import("../page.zig").Page;
2222const NodeList = @import ("nodelist.zig" ).NodeList ;
2323const Element = @import ("element.zig" ).Element ;
2424const ElementUnion = @import ("element.zig" ).Union ;
25+ const collection = @import ("html_collection.zig" );
2526
2627const Node = @import ("node.zig" ).Node ;
2728
@@ -71,6 +72,15 @@ pub const DocumentFragment = struct {
7172 pub fn _querySelectorAll (self : * parser.DocumentFragment , selector : []const u8 , page : * Page ) ! NodeList {
7273 return css .querySelectorAll (page .arena , parser .documentFragmentToNode (self ), selector );
7374 }
75+
76+ pub fn get_childElementCount (self : * parser.DocumentFragment ) ! u32 {
77+ var children = try get_children (self );
78+ return children .get_length ();
79+ }
80+
81+ pub fn get_children (self : * parser.DocumentFragment ) ! collection.HTMLCollection {
82+ return collection .HTMLCollectionChildren (parser .documentFragmentToNode (self ), false );
83+ }
7484};
7585
7686const testing = @import ("../../testing.zig" );
@@ -93,10 +103,13 @@ test "Browser.DOM.DocumentFragment" {
93103 try runner .testCases (&.{
94104 .{ "let f = document.createDocumentFragment()" , null },
95105 .{ "let d = document.createElement('div');" , null },
106+ .{ "d.childElementCount" , "0" },
107+
96108 .{ "d.id = 'x';" , null },
97109 .{ "document.getElementById('x') == null;" , "true" },
98-
99110 .{ "f.append(d);" , null },
111+ .{ "f.childElementCount" , "1" },
112+ .{ "f.children[0].id" , "x" },
100113 .{ "document.getElementById('x') == null;" , "true" },
101114
102115 .{ "document.getElementsByTagName('body')[0].append(f.cloneNode(true));" , null },
0 commit comments