From faa581be86e0a47c443c100a1e851ca442fb01bd Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Thu, 27 Aug 2015 13:39:47 +0200 Subject: [PATCH] Optimise most basic case of .replaceChild() when updating childNodes --- components/script/dom/nodelist.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/components/script/dom/nodelist.rs b/components/script/dom/nodelist.rs index eb3353a4d6e..514221f850d 100644 --- a/components/script/dom/nodelist.rs +++ b/components/script/dom/nodelist.rs @@ -218,7 +218,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)) => {