css: ensure node is an element before accessing to attr

This commit is contained in:
Pierre Tachoire
2024-03-26 11:08:25 +01:00
parent 4d5f6d42fa
commit 8eb4de9ccb

View File

@@ -74,6 +74,7 @@ pub const Node = struct {
}
pub fn attr(n: Node, key: []const u8) !?[]const u8 {
if (!n.isElement()) return null;
return try parser.elementGetAttribute(parser.nodeToElement(n.node), key);
}