css: add nth- pseudo class

This commit is contained in:
Pierre Tachoire
2024-03-25 08:50:57 +01:00
parent 9c997ec86d
commit db5d933285
4 changed files with 225 additions and 4 deletions

View File

@@ -13,6 +13,13 @@ pub const Node = struct {
return null;
}
pub fn lastChild(n: Node) !?Node {
const c = try parser.nodeLastChild(n.node);
if (c) |cc| return .{ .node = cc };
return null;
}
pub fn nextSibling(n: Node) !?Node {
const c = try parser.nodeNextSibling(n.node);
if (c) |cc| return .{ .node = cc };
@@ -20,6 +27,13 @@ pub const Node = struct {
return null;
}
pub fn prevSibling(n: Node) !?Node {
const c = try parser.nodePreviousSibling(n.node);
if (c) |cc| return .{ .node = cc };
return null;
}
pub fn parent(n: Node) !?Node {
const c = try parser.nodeParentNode(n.node);
if (c) |cc| return .{ .node = cc };
@@ -39,4 +53,8 @@ pub const Node = struct {
pub fn attr(n: Node, key: []const u8) !?[]const u8 {
return try parser.elementGetAttribute(parser.nodeToElement(n.node), key);
}
pub fn eql(a: Node, b: Node) bool {
return a.node == b.node;
}
};