Basic Implementation of document.getElementById(), #740

This commit is contained in:
Tetsuharu OHZEKI 2013-09-16 23:00:18 +09:00
parent f9be872e61
commit db3b5c3c4c
4 changed files with 126 additions and 4 deletions

View file

@ -473,6 +473,16 @@ impl Node<ScriptView> {
cur_node = cur_node.unwrap().next_sibling();
}
// Unregister elements having "id' from the old doc.
do old_doc.with_mut_base |old_doc| {
old_doc.unregister_nodes_with_id(&abstract_self);
}
// Register elements having "id" attribute to the owner doc.
do doc.with_mut_base |doc| {
doc.register_nodes_with_id(&abstract_self);
}
// Signal the old document that it needs to update its display
if old_doc != doc {
do old_doc.with_base |old_doc| {
@ -779,6 +789,12 @@ impl Node<ScriptView> {
self.wait_until_safe_to_modify_dom();
// Unregister elements having "id' from the owner doc.
// This need be called before target nodes are removed from tree.
do self.owner_doc.with_mut_base |doc| {
doc.unregister_nodes_with_id(&abstract_self);
}
abstract_self.remove_child(node);
// Signal the document that it needs to update its display.
do self.owner_doc.with_base |document| {