Feat: patch to diff to allow scopes

This commit is contained in:
Jonathan Kelley committed 2021-02-27 22:52:32 -05:00
1 parent e840f472fa
commit 2041c88d07
2 files changed
+13 -5

No files matched your search

+8 -4
View File
@@ -250,26 +250,30 @@ impl<'a> DiffMachine<'a> {
self.change_list.commit_traversal();
}
'outer1: for new_l in new {
'outer1: for (l_idx, new_l) in new.iter().enumerate() {
// unsafe {
// Safety relies on removing `new_l` from the registry manually at
// the end of its lifetime. This happens below in the `'outer2`
// loop, and elsewhere in diffing when removing old dom trees.
// registry.add(new_l);
// }
let event_type = new_l.event;
for (l_idx, old_l) in old.iter().enumerate() {
for old_l in old {
if new_l.event == old_l.event {
let event_type = new_l.event;
if let Some(scope) = self.current_idx {
let cb = CbIdx::from_gi_index(scope, l_idx);
self.change_list.update_event_listener(event_type, cb);
}
continue 'outer1;
}
}
self.change_list.new_event_listener(new_l);
if let Some(scope) = self.current_idx {
let cb = CbIdx::from_gi_index(scope, l_idx);
self.change_list.new_event_listener(event_type, cb);
}
}
'outer2: for old_l in old {
+5 -1
View File
@@ -98,7 +98,11 @@ impl VirtualDom {
component.run::<()>();
diff_machine.diff_node(component.old_frame(), component.new_frame());
diff_machine.diff_node(
component.old_frame(),
component.new_frame(),
Some(self.base_scope),
);
Ok(diff_machine.consume())
}