auto merge of #1110 : ILyoan/servo/parentNode, r=jdm

In this implemantation `GetParentNode()` just returns `self.parent_node`.
But according to MDN(https://developer.mozilla.org/en-US/docs/Web/API/Node.parentNode), it says.
"parentNode returns null for the following node types: Attr, Document, DocumentFragment, Entity, and Notation."

should this be checked?

r? @jdm
This commit is contained in:
bors-servo 2013-10-23 01:43:05 -07:00
commit c2116c3aa1
2 changed files with 28 additions and 2 deletions

View file

@ -592,11 +592,11 @@ impl Node<ScriptView> {
}
pub fn GetParentNode(&self) -> Option<AbstractNode<ScriptView>> {
None
self.parent_node
}
pub fn GetParentElement(&self) -> Option<AbstractNode<ScriptView>> {
None
self.parent_node.filtered(|parent| parent.is_element())
}
pub fn HasChildNodes(&self) -> bool {

View file

@ -0,0 +1,26 @@
<html>
<head>
<title></title>
<script src="harness.js"></script>
</head>
<body>
<div id="div1"></div>
<script>
// FIXME: This should be HTMLDocument.
//isnot(document.documentElement.parentNode, null);
is(document.documentElement.parentElement, null);
var elem = document.createElement("p");
is(elem.parentNode, null);
is(elem.parentElement, null);
var child = document.createElement("p");
elem.appendChild(child);
is(child.parentNode, elem);
is(child.parentElement, elem);
finish();
</script>
</body>
</html>