aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/nodelist.rs
diff options
context:
space:
mode:
authorbors-servo <metajack+bors@gmail.com>2015-08-30 13:22:41 -0600
committerbors-servo <metajack+bors@gmail.com>2015-08-30 13:22:41 -0600
commit86da67bb1e229f16b13892c42bd2a444b1b97644 (patch)
tree0108ba015b6364b317087eb0f2268279f15ef261 /components/script/dom/nodelist.rs
parent347e9b6ef45fb8b0e5a824944e4b1c7338d15554 (diff)
parentfaa581be86e0a47c443c100a1e851ca442fb01bd (diff)
downloadservo-86da67bb1e229f16b13892c42bd2a444b1b97644.tar.gz
servo-86da67bb1e229f16b13892c42bd2a444b1b97644.zip
Auto merge of #7407 - nox:childnodes-replace, r=jdm
Optimise most basic case of .replaceChild() when updating childNodes <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7407) <!-- Reviewable:end -->
Diffstat (limited to 'components/script/dom/nodelist.rs')
-rw-r--r--components/script/dom/nodelist.rs5
1 files changed, 4 insertions, 1 deletions
diff --git a/components/script/dom/nodelist.rs b/components/script/dom/nodelist.rs
index 01bc27d3a08..3e2bc5145c6 100644
--- a/components/script/dom/nodelist.rs
+++ b/components/script/dom/nodelist.rs
@@ -215,7 +215,10 @@ impl ChildrenList {
},
};
list.last_visited.set(Some(JS::from_ref(visited)));
- } else {
+ } else if added.len() != 1 {
+ // The replaced child isn't the last visited one, and there are
+ // 0 or more than 1 nodes to replace it. Special care must be
+ // given to update the state of that ChildrenList.
match (prev, next) {
(Some(_), None) => {},
(None, Some(next)) => {