@@ -190,6 +190,13 @@ fn diff_children(
190190 new: &[Node],
191191 cached_roots: &mut FxHashSet<CacheId>,
192192) {
193+ if new.is_empty() {
194+ if !old.is_empty() {
195+ remove_children(change_list, registry, old);
196+ }
197+ return;
198+ }
199+
193200 debug!(" updating children shared by old and new");
194201
195202 let num_children_to_diff = cmp::min(new.len(), old.len());
@@ -255,6 +262,19 @@ fn diff_children(
255262 }
256263}
257264
265+fn remove_children(
266+ change_list: &mut ChangeListBuilder,
267+ registry: &mut EventsRegistry,
268+ old: &[Node],
269+) {
270+ for child in old {
271+ registry.remove_subtree(child);
272+ }
273+ // Fast way to remove all children: set the node's textContent to an empty
274+ // string.
275+ change_list.set_text("");
276+}
277+
258278fn create(
259279 cached_set: &CachedSet,
260280 change_list: &mut ChangeListBuilder,