mirror of
https://github.com/servo/servo.git
synced 2025-06-21 15:49:04 +01:00
Implementation of node.parentNode/parentElement
This commit is contained in:
parent
f3f6e62f7f
commit
a4aa8b05f7
2 changed files with 28 additions and 2 deletions
|
@ -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 {
|
||||||
|
|
26
src/test/html/content/test_parentnodes.html
Normal file
26
src/test/html/content/test_parentnodes.html
Normal 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>
|
Loading…
Add table
Add a link
Reference in a new issue