Skip to content

Commit

Permalink
Implementation of node.parentNode/parentElement
Browse files Browse the repository at this point in the history
  • Loading branch information
ILyoan committed Oct 23, 2013
1 parent f3f6e62 commit a4aa8b0
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/components/script/dom/node.rs
Expand Up @@ -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 {
Expand Down
26 changes: 26 additions & 0 deletions src/test/html/content/test_parentnodes.html
@@ -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>

5 comments on commit a4aa8b0

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from jdm
at ILyoan@a4aa8b0

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging ILyoan/servo/parentNode = a4aa8b0 into auto

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ILyoan/servo/parentNode = a4aa8b0 merged ok, testing candidate = c2116c3

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = c2116c3

Please sign in to comment.