diff options
author | bors-servo <metajack+bors@gmail.com> | 2015-07-25 11:39:20 -0600 |
---|---|---|
committer | bors-servo <metajack+bors@gmail.com> | 2015-07-25 11:39:20 -0600 |
commit | 705c95dedbbaa60ffd08e70579915e228d5b6ee0 (patch) | |
tree | 4cbafee85f191cfbd96986b4d520610adb27a26c /components/script/dom/virtualmethods.rs | |
parent | 8edf1a5ecdecc9f6de8210fc875cff3679fda09e (diff) | |
parent | 7b40cc9fd7ea4dcc3816be0cb1ad6543bb5c88e0 (diff) | |
download | servo-705c95dedbbaa60ffd08e70579915e228d5b6ee0.tar.gz servo-705c95dedbbaa60ffd08e70579915e228d5b6ee0.zip |
Auto merge of #6660 - nox:children-changed, r=jdm
Introduce VirtualMethods::children_changed()
This virtual method mimics the behaviour of mutation observers and make it more viable than the older child_inserted(), which didn't cover removed nodes and was called as many times as there were inserted nodes.
A few other shortcomings where remove_child() was called directly instead of Node::remove() were also fixed while at it.
<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/6660)
<!-- Reviewable:end -->
Diffstat (limited to 'components/script/dom/virtualmethods.rs')
-rw-r--r-- | components/script/dom/virtualmethods.rs | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/components/script/dom/virtualmethods.rs b/components/script/dom/virtualmethods.rs index 8bb62637ac6..88cc024acd5 100644 --- a/components/script/dom/virtualmethods.rs +++ b/components/script/dom/virtualmethods.rs @@ -35,7 +35,8 @@ use dom::document::Document; use dom::element::ElementTypeId; use dom::event::Event; use dom::htmlelement::HTMLElementTypeId; -use dom::node::{Node, NodeHelpers, NodeTypeId, CloneChildrenFlag}; +use dom::node::{ChildrenMutation, CloneChildrenFlag, Node, NodeHelpers}; +use dom::node::NodeTypeId; use util::str::DOMString; @@ -97,10 +98,10 @@ pub trait VirtualMethods { } } - /// Called on the parent when a node is added to its child list. - fn child_inserted(&self, child: &Node) { + /// Called on the parent when its children are changed. + fn children_changed(&self, mutation: &ChildrenMutation) { if let Some(ref s) = self.super_type() { - s.child_inserted(child); + s.children_changed(mutation); } } |