make Node.isConnected() shadowroot-aware

This commit is contained in:
Karl Seguin
2026-01-10 08:24:12 +08:00
parent 6917aeb47b
commit 05f0f8901e

View File

@@ -378,8 +378,14 @@ pub fn isConnected(self: *const Node) bool {
root = parent;
}
// A node is connected if its root is a document
return root._type == .document;
switch (root._type) {
.document => return true,
.document_fragment => |df| {
const sr = df.is(ShadowRoot) orelse return false;
return sr._host.asNode().isConnected();
},
else => return false,
}
}
const GetRootNodeOpts = struct {