Implementation of node.parentNode/parentElement

This commit is contained in:
Ilyong Cho 2013-10-23 17:04:57 +09:00
parent f3f6e62f7f
commit a4aa8b05f7
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>> { pub fn GetParentNode(&self) -> Option<AbstractNode<ScriptView>> {
None self.parent_node
} }
pub fn GetParentElement(&self) -> Option<AbstractNode<ScriptView>> { pub fn GetParentElement(&self) -> Option<AbstractNode<ScriptView>> {
None self.parent_node.filtered(|parent| parent.is_element())
} }
pub fn HasChildNodes(&self) -> bool { 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>