Auto merge of #10757 - ineol:root-node, r=Ms2ger

Implement Node::rootNode

Fixes #10747.

I don't know whether it's OK to recurse up the tree, though it is a tail call.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/10757)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2016-04-22 12:10:52 -07:00
commit 82938547ed
4 changed files with 7 additions and 66 deletions

View file

@ -1858,6 +1858,11 @@ impl NodeMethods for Node {
}
}
// https://dom.spec.whatwg.org/#dom-node-rootnode
fn RootNode(&self) -> Root<Node> {
self.inclusive_ancestors().last().unwrap()
}
// https://dom.spec.whatwg.org/#dom-node-parentnode
fn GetParentNode(&self) -> Option<Root<Node>> {
self.parent_node.get()

View file

@ -31,6 +31,8 @@ interface Node : EventTarget {
[Pure]
readonly attribute Document? ownerDocument;
[Pure]
readonly attribute Node rootNode;
[Pure]
readonly attribute Node? parentNode;
[Pure]
readonly attribute Element? parentElement;