mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Implement NodeHelpers::index()
This commit is contained in:
parent
d8c5092a6e
commit
bc8b7952b8
1 changed files with 6 additions and 0 deletions
|
@ -428,6 +428,7 @@ pub trait NodeHelpers {
|
|||
|
||||
fn type_id(self) -> NodeTypeId;
|
||||
fn len(self) -> u32;
|
||||
fn index(self) -> u32;
|
||||
|
||||
fn parent_node(self) -> Option<Temporary<Node>>;
|
||||
fn first_child(self) -> Option<Temporary<Node>>;
|
||||
|
@ -579,6 +580,11 @@ impl<'a> NodeHelpers for JSRef<'a, Node> {
|
|||
}
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#concept-tree-index
|
||||
fn index(self) -> u32 {
|
||||
self.preceding_siblings().count() as u32
|
||||
}
|
||||
|
||||
fn parent_node(self) -> Option<Temporary<Node>> {
|
||||
self.parent_node.get().map(Temporary::from_rooted)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue