diff options
Diffstat (limited to 'src/components/script/dom/node.rs')
-rw-r--r-- | src/components/script/dom/node.rs | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/components/script/dom/node.rs b/src/components/script/dom/node.rs index d9ee80edaa1..edd108e6881 100644 --- a/src/components/script/dom/node.rs +++ b/src/components/script/dom/node.rs @@ -264,6 +264,11 @@ impl<'self, View> AbstractNode<View> { self.with_base(|b| b.next_sibling) } + /// Is this node a root? + pub fn is_root(self) -> bool { + self.parent_node().is_none() + } + // // Downcasting borrows // @@ -415,10 +420,7 @@ impl<'self, View> AbstractNode<View> { impl<View> Iterator<AbstractNode<View>> for AbstractNodeChildrenIterator<View> { pub fn next(&mut self) -> Option<AbstractNode<View>> { let node = self.current_node; - self.current_node = match self.current_node { - None => None, - Some(node) => node.next_sibling(), - }; + self.current_node = self.current_node.chain(|node| node.next_sibling()); node } } |