Auto merge of #5781 - jdm:reparent, r=Ms2ger

Fixes html5test.com.

r? @Ms2ger

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/5781)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2015-04-22 13:01:32 -05:00
commit 9ae3cad31e
3 changed files with 35 additions and 5 deletions

View file

@ -166,8 +166,11 @@ impl<'a> TreeSink for servohtmlparser::Sink {
}
}
fn remove_from_parent(&mut self, _target: JS<Node>) {
error!("remove_from_parent not implemented!");
fn remove_from_parent(&mut self, target: JS<Node>) {
let node = target.root();
if let Some(ref parent) = node.r().GetParentNode().root() {
parent.r().RemoveChild(node.r()).unwrap();
}
}
fn mark_script_already_started(&mut self, node: JS<Node>) {
@ -182,8 +185,15 @@ impl<'a> TreeSink for servohtmlparser::Sink {
script.map(|script| script.prepare());
}
fn reparent_children(&mut self, _node: JS<Node>, _new_parent: JS<Node>) {
panic!("unimplemented")
fn reparent_children(&mut self, node: JS<Node>, new_parent: JS<Node>) {
let new_parent = new_parent.root();
let new_parent = new_parent.r();
let old_parent = node.root();
let old_parent = old_parent.r();
while let Some(ref child) = old_parent.GetFirstChild().root() {
new_parent.AppendChild(child.r()).unwrap();
}
}
}

View file

@ -71,6 +71,12 @@
"url": "/_mozilla/mozilla/characterdata.html"
}
],
"mozilla/child_reparenting.html": [
{
"path": "mozilla/child_reparenting.html",
"url": "/_mozilla/mozilla/child_reparenting.html"
}
],
"mozilla/collections.html": [
{
"path": "mozilla/collections.html",

View file

@ -0,0 +1,14 @@
<html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body><font><p></font>
<script>
test(function() {
assert_equals(document.body.firstChild.tagName, "FONT");
assert_equals(document.body.firstChild.nextSibling.tagName, "P");
});
</script>
</body>
</html>