mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-29 07:03:29 +00:00
characterdata: add previouselementSibling getter
Signed-off-by: Francis Bouvier <francis.bouvier@gmail.com>
This commit is contained in:
@@ -270,14 +270,14 @@ pub fn nodeNextSibling(node: *Node) ?*Node {
|
||||
pub fn nodeNextElementSibling(node: *Node) ?*Element {
|
||||
var n = node;
|
||||
while (true) {
|
||||
const next = nodeNextSibling(n);
|
||||
if (next == null) {
|
||||
const res = nodeNextSibling(n);
|
||||
if (res == null) {
|
||||
return null;
|
||||
}
|
||||
if (nodeType(next.?) == .element) {
|
||||
return @as(*Element, @ptrCast(next.?));
|
||||
if (nodeType(res.?) == .element) {
|
||||
return @as(*Element, @ptrCast(res.?));
|
||||
}
|
||||
n = next.?;
|
||||
n = res.?;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -288,6 +288,21 @@ pub fn nodePreviousSibling(node: *Node) ?*Node {
|
||||
return res;
|
||||
}
|
||||
|
||||
pub fn nodePreviousElementSibling(node: *Node) ?*Element {
|
||||
var n = node;
|
||||
while (true) {
|
||||
const res = nodePreviousSibling(n);
|
||||
if (res == null) {
|
||||
return null;
|
||||
}
|
||||
if (nodeType(res.?) == .element) {
|
||||
return @as(*Element, @ptrCast(res.?));
|
||||
}
|
||||
n = res.?;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
pub fn nodeParentNode(node: *Node) ?*Node {
|
||||
var res: ?*Node = undefined;
|
||||
_ = nodeVtable(node).dom_node_get_parent_node.?(node, &res);
|
||||
|
||||
Reference in New Issue
Block a user