Skip to content

Commit

Permalink
fixes #5963
Browse files Browse the repository at this point in the history
  • Loading branch information
pgonda committed May 26, 2015
1 parent 387836c commit 7239d67
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 8 deletions.
10 changes: 3 additions & 7 deletions components/script/dom/node.rs
Expand Up @@ -304,6 +304,7 @@ impl<'a> PrivateNodeHelpers for JSRef<'a, Node> {
assert!(self.parent_node.get().is_none());
for node in self.traverse_preorder() {
let node = node.root();
node.r().set_flag(IS_IN_DOC, false);
vtable_for(&node.r()).unbind_from_tree(parent_in_doc);
}
self.layout_data.dispose();
Expand Down Expand Up @@ -1658,21 +1659,16 @@ impl Node {
}

// https://dom.spec.whatwg.org/#concept-node-remove
fn remove(node: JSRef<Node>, parent: JSRef<Node>, suppress_observers: SuppressObserver) {
fn remove(node: JSRef<Node>, parent: JSRef<Node>, _suppress_observers: SuppressObserver) {
assert!(node.GetParentNode().map_or(false, |node_parent| node_parent == Temporary::from_rooted(parent)));

// Step 1-5: ranges.
// Step 6-7: mutation observers.
// Step 8.
parent.remove_child(node);

node.set_flag(IS_IN_DOC, false);

// Step 9.
match suppress_observers {
SuppressObserver::Suppressed => (),
SuppressObserver::Unsuppressed => node.node_removed(parent.is_in_doc()),
}
node.node_removed(parent.is_in_doc());
}

// https://dom.spec.whatwg.org/#concept-node-clone
Expand Down
2 changes: 1 addition & 1 deletion support/android-rs-glue
Expand Up @@ -20,6 +20,13 @@
<input id="test5" type="submit" value="Submit" data-name="3rd">
</div>

<!-- test 15 -->
<div id="outer">
<div id="middle">
<div id="inner"></div>
</div>
</div>

<script>
var gBody = document.getElementsByTagName("body")[0];

Expand Down Expand Up @@ -300,6 +307,21 @@
assert_equals(document.getElementById(TEST_ID), b);
}, "Inserting an id by inserting its parent node");

test(function () {
var TEST_ID = "test15"
var outer = document.getElementById("outer");
var middle = document.getElementById("middle");
var inner = document.getElementById("inner");
outer.removeChild(middle);

var new_el = document.createElement("h1");
new_el.id = "heading";
inner.appendChild(new_el);
// the new element is not part of the document since
// "middle" element was removed previously
assert_equals(document.getElementById("heading"), null);
}, "Document.getElementById must not return nodes not present in document");

// TODO:
// id attribute in a namespace

Expand Down

0 comments on commit 7239d67

Please sign in to comment.