diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs index d8c23b559d9..3cbe8024b9e 100644 --- a/components/script/dom/node.rs +++ b/components/script/dom/node.rs @@ -1858,6 +1858,11 @@ impl NodeMethods for Node { } } + // https://dom.spec.whatwg.org/#dom-node-rootnode + fn RootNode(&self) -> Root { + self.inclusive_ancestors().last().unwrap() + } + // https://dom.spec.whatwg.org/#dom-node-parentnode fn GetParentNode(&self) -> Option> { self.parent_node.get() diff --git a/components/script/dom/webidls/Node.webidl b/components/script/dom/webidls/Node.webidl index 871e865e03a..01df71dbdd2 100644 --- a/components/script/dom/webidls/Node.webidl +++ b/components/script/dom/webidls/Node.webidl @@ -32,6 +32,8 @@ interface Node : EventTarget { [Pure] readonly attribute Document? ownerDocument; [Pure] + readonly attribute Node rootNode; + [Pure] readonly attribute Node? parentNode; [Pure] readonly attribute Element? parentElement; diff --git a/tests/wpt/metadata/dom/interfaces.html.ini b/tests/wpt/metadata/dom/interfaces.html.ini index 1298cc1e92b..8d92df54e4f 100644 --- a/tests/wpt/metadata/dom/interfaces.html.ini +++ b/tests/wpt/metadata/dom/interfaces.html.ini @@ -165,9 +165,6 @@ [DOMTokenList interface: calling supports(DOMString) on document.body.classList with too few arguments must throw TypeError] expected: FAIL - [Node interface: attribute rootNode] - expected: FAIL - [Document interface: new Document() must inherit property "origin" with the proper type (3)] expected: FAIL @@ -183,30 +180,6 @@ [Document interface: calling queryAll(DOMString) on new Document() with too few arguments must throw TypeError] expected: FAIL - [Node interface: new Document() must inherit property "rootNode" with the proper type (16)] - expected: FAIL - - [Node interface: xmlDoc must inherit property "rootNode" with the proper type (16)] - expected: FAIL - - [Node interface: document.createDocumentFragment() must inherit property "rootNode" with the proper type (16)] - expected: FAIL - - [Node interface: document.doctype must inherit property "rootNode" with the proper type (16)] - expected: FAIL - - [Node interface: element must inherit property "rootNode" with the proper type (16)] - expected: FAIL - - [Node interface: document.createTextNode("abc") must inherit property "rootNode" with the proper type (16)] - expected: FAIL - - [Node interface: xmlDoc.createProcessingInstruction("abc", "def") must inherit property "rootNode" with the proper type (16)] - expected: FAIL - - [Node interface: document.createComment("abc") must inherit property "rootNode" with the proper type (16)] - expected: FAIL - [Element interface: element must inherit property "query" with the proper type (36)] expected: FAIL @@ -222,9 +195,6 @@ [Node interface: new Document() must inherit property "isConnected" with the proper type (15)] expected: FAIL - [Node interface: new Document() must inherit property "rootNode" with the proper type (17)] - expected: FAIL - [Node interface: new Document() must inherit property "isSameNode" with the proper type (31)] expected: FAIL @@ -234,9 +204,6 @@ [Node interface: xmlDoc must inherit property "isConnected" with the proper type (15)] expected: FAIL - [Node interface: xmlDoc must inherit property "rootNode" with the proper type (17)] - expected: FAIL - [Node interface: xmlDoc must inherit property "isSameNode" with the proper type (31)] expected: FAIL @@ -246,9 +213,6 @@ [Node interface: document.doctype must inherit property "isConnected" with the proper type (15)] expected: FAIL - [Node interface: document.doctype must inherit property "rootNode" with the proper type (17)] - expected: FAIL - [Node interface: document.doctype must inherit property "isSameNode" with the proper type (31)] expected: FAIL @@ -258,9 +222,6 @@ [Node interface: document.createDocumentFragment() must inherit property "isConnected" with the proper type (15)] expected: FAIL - [Node interface: document.createDocumentFragment() must inherit property "rootNode" with the proper type (17)] - expected: FAIL - [Node interface: document.createDocumentFragment() must inherit property "isSameNode" with the proper type (31)] expected: FAIL @@ -321,9 +282,6 @@ [Node interface: element must inherit property "isConnected" with the proper type (15)] expected: FAIL - [Node interface: element must inherit property "rootNode" with the proper type (17)] - expected: FAIL - [Node interface: element must inherit property "isSameNode" with the proper type (31)] expected: FAIL @@ -339,9 +297,6 @@ [Node interface: document.createTextNode("abc") must inherit property "isConnected" with the proper type (15)] expected: FAIL - [Node interface: document.createTextNode("abc") must inherit property "rootNode" with the proper type (17)] - expected: FAIL - [Node interface: document.createTextNode("abc") must inherit property "isSameNode" with the proper type (31)] expected: FAIL @@ -351,9 +306,6 @@ [Node interface: xmlDoc.createProcessingInstruction("abc", "def") must inherit property "isConnected" with the proper type (15)] expected: FAIL - [Node interface: xmlDoc.createProcessingInstruction("abc", "def") must inherit property "rootNode" with the proper type (17)] - expected: FAIL - [Node interface: xmlDoc.createProcessingInstruction("abc", "def") must inherit property "isSameNode" with the proper type (31)] expected: FAIL @@ -363,9 +315,6 @@ [Node interface: document.createComment("abc") must inherit property "isConnected" with the proper type (15)] expected: FAIL - [Node interface: document.createComment("abc") must inherit property "rootNode" with the proper type (17)] - expected: FAIL - [Node interface: document.createComment("abc") must inherit property "isSameNode" with the proper type (31)] expected: FAIL diff --git a/tests/wpt/metadata/dom/nodes/rootNode.html.ini b/tests/wpt/metadata/dom/nodes/rootNode.html.ini deleted file mode 100644 index 8505eb99f81..00000000000 --- a/tests/wpt/metadata/dom/nodes/rootNode.html.ini +++ /dev/null @@ -1,15 +0,0 @@ -[rootNode.html] - type: testharness - bug: https://github.com/servo/servo/issues/10747 - [rootNode attribute must return the context object when it does not have any parent] - expected: FAIL - - [rootNode attribute must return the parent node of the context object when the context object has a single ancestor not in a document] - expected: FAIL - - [rootNode attribute must return the document when a node is in document] - expected: FAIL - - [rootNode attribute must return a document fragment when a node is in the fragment] - expected: FAIL -