mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-11-23 12:43:08 +00:00
wip: bubbling reserves nodes
This commit is contained in:
parent
a21020ea57
commit
b6262edd53
6 changed files with 135 additions and 137 deletions
|
@ -244,7 +244,8 @@ impl<'bump> DiffState<'bump> {
|
||||||
let (old, new) = (self.scopes.wip_head(id), self.scopes.fin_head(id));
|
let (old, new) = (self.scopes.wip_head(id), self.scopes.fin_head(id));
|
||||||
self.stack.push(DiffInstruction::Diff { old, new });
|
self.stack.push(DiffInstruction::Diff { old, new });
|
||||||
self.stack.scope_stack.push(*id);
|
self.stack.scope_stack.push(*id);
|
||||||
self.stack.push_nodes_created(0);
|
let scope = self.scopes.get_scope(id).unwrap();
|
||||||
|
self.stack.element_stack.push(scope.container);
|
||||||
self.work(|| false);
|
self.work(|| false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -219,9 +219,6 @@ fn round_to_words(len: usize) -> usize {
|
||||||
fn it_works() {
|
fn it_works() {
|
||||||
let bump = bumpalo::Bump::new();
|
let bump = bumpalo::Bump::new();
|
||||||
|
|
||||||
#[cfg(not(miri))]
|
|
||||||
simple_logger::init().unwrap();
|
|
||||||
|
|
||||||
let factory = NodeFactory { bump: &bump };
|
let factory = NodeFactory { bump: &bump };
|
||||||
|
|
||||||
let caller = NodeFactory::annotate_lazy(|f| {
|
let caller = NodeFactory::annotate_lazy(|f| {
|
||||||
|
@ -240,9 +237,6 @@ fn it_drops() {
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
let bump = bumpalo::Bump::new();
|
let bump = bumpalo::Bump::new();
|
||||||
|
|
||||||
#[cfg(not(miri))]
|
|
||||||
simple_logger::init().unwrap();
|
|
||||||
|
|
||||||
let factory = NodeFactory { bump: &bump };
|
let factory = NodeFactory { bump: &bump };
|
||||||
|
|
||||||
struct DropInner {
|
struct DropInner {
|
||||||
|
|
|
@ -446,10 +446,10 @@ impl VirtualDom {
|
||||||
self.scopes.wip_head(&scopeid),
|
self.scopes.wip_head(&scopeid),
|
||||||
self.scopes.fin_head(&scopeid),
|
self.scopes.fin_head(&scopeid),
|
||||||
);
|
);
|
||||||
|
diff_state.stack.push(DiffInstruction::Diff { new, old });
|
||||||
diff_state.stack.scope_stack.push(scopeid);
|
diff_state.stack.scope_stack.push(scopeid);
|
||||||
let scope = scopes.get_scope(&scopeid).unwrap();
|
let scope = scopes.get_scope(&scopeid).unwrap();
|
||||||
diff_state.stack.element_stack.push(scope.container);
|
diff_state.stack.element_stack.push(scope.container);
|
||||||
diff_state.stack.push(DiffInstruction::Diff { new, old });
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -576,6 +576,7 @@ impl VirtualDom {
|
||||||
pub fn diff_vnodes<'a>(&'a self, old: &'a VNode<'a>, new: &'a VNode<'a>) -> Mutations<'a> {
|
pub fn diff_vnodes<'a>(&'a self, old: &'a VNode<'a>, new: &'a VNode<'a>) -> Mutations<'a> {
|
||||||
let mut machine = DiffState::new(&self.scopes);
|
let mut machine = DiffState::new(&self.scopes);
|
||||||
machine.stack.push(DiffInstruction::Diff { new, old });
|
machine.stack.push(DiffInstruction::Diff { new, old });
|
||||||
|
machine.stack.element_stack.push(ElementId(0));
|
||||||
machine.stack.scope_stack.push(self.base_scope);
|
machine.stack.scope_stack.push(self.base_scope);
|
||||||
machine.work(|| false);
|
machine.work(|| false);
|
||||||
machine.mutations
|
machine.mutations
|
||||||
|
@ -587,6 +588,7 @@ impl VirtualDom {
|
||||||
pub fn create_vnodes<'a>(&'a self, left: Option<LazyNodes<'a, '_>>) -> Mutations<'a> {
|
pub fn create_vnodes<'a>(&'a self, left: Option<LazyNodes<'a, '_>>) -> Mutations<'a> {
|
||||||
let nodes = self.render_vnodes(left);
|
let nodes = self.render_vnodes(left);
|
||||||
let mut machine = DiffState::new(&self.scopes);
|
let mut machine = DiffState::new(&self.scopes);
|
||||||
|
machine.stack.element_stack.push(ElementId(0));
|
||||||
machine.stack.create_node(nodes, MountType::Append);
|
machine.stack.create_node(nodes, MountType::Append);
|
||||||
machine.work(|| false);
|
machine.work(|| false);
|
||||||
machine.mutations
|
machine.mutations
|
||||||
|
@ -604,11 +606,13 @@ impl VirtualDom {
|
||||||
|
|
||||||
let mut create = DiffState::new(&self.scopes);
|
let mut create = DiffState::new(&self.scopes);
|
||||||
create.stack.scope_stack.push(self.base_scope);
|
create.stack.scope_stack.push(self.base_scope);
|
||||||
|
create.stack.element_stack.push(ElementId(0));
|
||||||
create.stack.create_node(old, MountType::Append);
|
create.stack.create_node(old, MountType::Append);
|
||||||
create.work(|| false);
|
create.work(|| false);
|
||||||
|
|
||||||
let mut edit = DiffState::new(&self.scopes);
|
let mut edit = DiffState::new(&self.scopes);
|
||||||
create.stack.scope_stack.push(self.base_scope);
|
edit.stack.scope_stack.push(self.base_scope);
|
||||||
|
edit.stack.element_stack.push(ElementId(0));
|
||||||
edit.stack.push(DiffInstruction::Diff { old, new });
|
edit.stack.push(DiffInstruction::Diff { old, new });
|
||||||
edit.work(&mut || false);
|
edit.work(&mut || false);
|
||||||
|
|
||||||
|
|
|
@ -32,11 +32,11 @@ fn html_and_rsx_generate_the_same_output() {
|
||||||
create.edits,
|
create.edits,
|
||||||
[
|
[
|
||||||
CreateElement {
|
CreateElement {
|
||||||
root: 0,
|
root: 1,
|
||||||
tag: "div"
|
tag: "div"
|
||||||
},
|
},
|
||||||
CreateTextNode {
|
CreateTextNode {
|
||||||
root: 1,
|
root: 2,
|
||||||
text: "Hello world"
|
text: "Hello world"
|
||||||
},
|
},
|
||||||
AppendChildren { many: 1 },
|
AppendChildren { many: 1 },
|
||||||
|
@ -48,7 +48,7 @@ fn html_and_rsx_generate_the_same_output() {
|
||||||
change.edits,
|
change.edits,
|
||||||
[SetText {
|
[SetText {
|
||||||
text: "Goodbye world",
|
text: "Goodbye world",
|
||||||
root: 1
|
root: 2
|
||||||
},]
|
},]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -68,29 +68,29 @@ fn fragments_create_properly() {
|
||||||
create.edits,
|
create.edits,
|
||||||
[
|
[
|
||||||
CreateElement {
|
CreateElement {
|
||||||
root: 0,
|
root: 1,
|
||||||
tag: "div"
|
tag: "div"
|
||||||
},
|
},
|
||||||
CreateTextNode {
|
CreateTextNode {
|
||||||
root: 1,
|
root: 2,
|
||||||
text: "Hello a"
|
text: "Hello a"
|
||||||
},
|
},
|
||||||
AppendChildren { many: 1 },
|
AppendChildren { many: 1 },
|
||||||
CreateElement {
|
CreateElement {
|
||||||
root: 2,
|
root: 3,
|
||||||
tag: "div"
|
tag: "div"
|
||||||
},
|
},
|
||||||
CreateTextNode {
|
CreateTextNode {
|
||||||
root: 3,
|
root: 4,
|
||||||
text: "Hello b"
|
text: "Hello b"
|
||||||
},
|
},
|
||||||
AppendChildren { many: 1 },
|
AppendChildren { many: 1 },
|
||||||
CreateElement {
|
CreateElement {
|
||||||
root: 4,
|
root: 5,
|
||||||
tag: "div"
|
tag: "div"
|
||||||
},
|
},
|
||||||
CreateTextNode {
|
CreateTextNode {
|
||||||
root: 5,
|
root: 6,
|
||||||
text: "Hello c"
|
text: "Hello c"
|
||||||
},
|
},
|
||||||
AppendChildren { many: 1 },
|
AppendChildren { many: 1 },
|
||||||
|
@ -111,16 +111,16 @@ fn empty_fragments_create_anchors() {
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
create.edits,
|
create.edits,
|
||||||
[CreatePlaceholder { root: 0 }, AppendChildren { many: 1 }]
|
[CreatePlaceholder { root: 1 }, AppendChildren { many: 1 }]
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
change.edits,
|
change.edits,
|
||||||
[
|
[
|
||||||
CreateElement {
|
CreateElement {
|
||||||
root: 1,
|
root: 2,
|
||||||
tag: "div"
|
tag: "div"
|
||||||
},
|
},
|
||||||
ReplaceWith { m: 1, root: 0 }
|
ReplaceWith { m: 1, root: 1 }
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -136,15 +136,11 @@ fn empty_fragments_create_many_anchors() {
|
||||||
let (create, change) = dom.diff_lazynodes(left, right);
|
let (create, change) = dom.diff_lazynodes(left, right);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
create.edits,
|
create.edits,
|
||||||
[CreatePlaceholder { root: 0 }, AppendChildren { many: 1 }]
|
[CreatePlaceholder { root: 1 }, AppendChildren { many: 1 }]
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
change.edits,
|
change.edits,
|
||||||
[
|
[
|
||||||
CreateElement {
|
|
||||||
root: 1,
|
|
||||||
tag: "div"
|
|
||||||
},
|
|
||||||
CreateElement {
|
CreateElement {
|
||||||
root: 2,
|
root: 2,
|
||||||
tag: "div"
|
tag: "div"
|
||||||
|
@ -161,7 +157,11 @@ fn empty_fragments_create_many_anchors() {
|
||||||
root: 5,
|
root: 5,
|
||||||
tag: "div"
|
tag: "div"
|
||||||
},
|
},
|
||||||
ReplaceWith { m: 5, root: 0 }
|
CreateElement {
|
||||||
|
root: 6,
|
||||||
|
tag: "div"
|
||||||
|
},
|
||||||
|
ReplaceWith { m: 5, root: 1 }
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -182,39 +182,39 @@ fn empty_fragments_create_anchors_with_many_children() {
|
||||||
let (create, change) = dom.diff_lazynodes(left, right);
|
let (create, change) = dom.diff_lazynodes(left, right);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
create.edits,
|
create.edits,
|
||||||
[CreatePlaceholder { root: 0 }, AppendChildren { many: 1 }]
|
[CreatePlaceholder { root: 1 }, AppendChildren { many: 1 }]
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
change.edits,
|
change.edits,
|
||||||
[
|
[
|
||||||
CreateElement {
|
CreateElement {
|
||||||
root: 1,
|
root: 2,
|
||||||
tag: "div"
|
tag: "div"
|
||||||
},
|
},
|
||||||
CreateTextNode {
|
CreateTextNode {
|
||||||
text: "hello: 0",
|
text: "hello: 0",
|
||||||
root: 2
|
root: 3
|
||||||
},
|
},
|
||||||
AppendChildren { many: 1 },
|
AppendChildren { many: 1 },
|
||||||
CreateElement {
|
CreateElement {
|
||||||
root: 3,
|
root: 4,
|
||||||
tag: "div"
|
tag: "div"
|
||||||
},
|
},
|
||||||
CreateTextNode {
|
CreateTextNode {
|
||||||
text: "hello: 1",
|
text: "hello: 1",
|
||||||
root: 4
|
root: 5
|
||||||
},
|
},
|
||||||
AppendChildren { many: 1 },
|
AppendChildren { many: 1 },
|
||||||
CreateElement {
|
CreateElement {
|
||||||
root: 5,
|
root: 6,
|
||||||
tag: "div"
|
tag: "div"
|
||||||
},
|
},
|
||||||
CreateTextNode {
|
CreateTextNode {
|
||||||
text: "hello: 2",
|
text: "hello: 2",
|
||||||
root: 6
|
root: 7
|
||||||
},
|
},
|
||||||
AppendChildren { many: 1 },
|
AppendChildren { many: 1 },
|
||||||
ReplaceWith { m: 3, root: 0 }
|
ReplaceWith { m: 3, root: 1 }
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -236,21 +236,21 @@ fn many_items_become_fragment() {
|
||||||
create.edits,
|
create.edits,
|
||||||
[
|
[
|
||||||
CreateElement {
|
CreateElement {
|
||||||
root: 0,
|
root: 1,
|
||||||
tag: "div"
|
tag: "div"
|
||||||
},
|
},
|
||||||
CreateTextNode {
|
CreateTextNode {
|
||||||
text: "hello",
|
text: "hello",
|
||||||
root: 1
|
root: 2
|
||||||
},
|
},
|
||||||
AppendChildren { many: 1 },
|
AppendChildren { many: 1 },
|
||||||
CreateElement {
|
CreateElement {
|
||||||
root: 2,
|
root: 3,
|
||||||
tag: "div"
|
tag: "div"
|
||||||
},
|
},
|
||||||
CreateTextNode {
|
CreateTextNode {
|
||||||
text: "hello",
|
text: "hello",
|
||||||
root: 3
|
root: 4
|
||||||
},
|
},
|
||||||
AppendChildren { many: 1 },
|
AppendChildren { many: 1 },
|
||||||
AppendChildren { many: 2 },
|
AppendChildren { many: 2 },
|
||||||
|
@ -261,9 +261,9 @@ fn many_items_become_fragment() {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
change.edits,
|
change.edits,
|
||||||
[
|
[
|
||||||
Remove { root: 2 },
|
Remove { root: 3 },
|
||||||
CreatePlaceholder { root: 3 },
|
CreatePlaceholder { root: 4 },
|
||||||
ReplaceWith { root: 0, m: 1 },
|
ReplaceWith { root: 1, m: 1 },
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -308,15 +308,15 @@ fn two_fragments_with_differrent_elements_are_differet() {
|
||||||
changes.edits,
|
changes.edits,
|
||||||
[
|
[
|
||||||
// create the new h1s
|
// create the new h1s
|
||||||
CreateElement { tag: "h1", root: 3 },
|
|
||||||
CreateElement { tag: "h1", root: 4 },
|
CreateElement { tag: "h1", root: 4 },
|
||||||
CreateElement { tag: "h1", root: 5 },
|
CreateElement { tag: "h1", root: 5 },
|
||||||
InsertAfter { root: 1, n: 3 },
|
|
||||||
// replace the divs with new h1s
|
|
||||||
CreateElement { tag: "h1", root: 6 },
|
CreateElement { tag: "h1", root: 6 },
|
||||||
ReplaceWith { root: 0, m: 1 },
|
InsertAfter { root: 2, n: 3 },
|
||||||
|
// replace the divs with new h1s
|
||||||
CreateElement { tag: "h1", root: 7 },
|
CreateElement { tag: "h1", root: 7 },
|
||||||
ReplaceWith { root: 1, m: 1 },
|
ReplaceWith { root: 1, m: 1 },
|
||||||
|
CreateElement { tag: "h1", root: 8 },
|
||||||
|
ReplaceWith { root: 2, m: 1 },
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -339,10 +339,6 @@ fn two_fragments_with_differrent_elements_are_differet_shorter() {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
create.edits,
|
create.edits,
|
||||||
[
|
[
|
||||||
CreateElement {
|
|
||||||
root: 0,
|
|
||||||
tag: "div"
|
|
||||||
},
|
|
||||||
CreateElement {
|
CreateElement {
|
||||||
root: 1,
|
root: 1,
|
||||||
tag: "div"
|
tag: "div"
|
||||||
|
@ -359,20 +355,24 @@ fn two_fragments_with_differrent_elements_are_differet_shorter() {
|
||||||
root: 4,
|
root: 4,
|
||||||
tag: "div"
|
tag: "div"
|
||||||
},
|
},
|
||||||
CreateElement { root: 5, tag: "p" },
|
CreateElement {
|
||||||
|
root: 5,
|
||||||
|
tag: "div"
|
||||||
|
},
|
||||||
|
CreateElement { root: 6, tag: "p" },
|
||||||
AppendChildren { many: 6 },
|
AppendChildren { many: 6 },
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
change.edits,
|
change.edits,
|
||||||
[
|
[
|
||||||
Remove { root: 2 },
|
|
||||||
Remove { root: 3 },
|
Remove { root: 3 },
|
||||||
Remove { root: 4 },
|
Remove { root: 4 },
|
||||||
CreateElement { root: 6, tag: "h1" },
|
Remove { root: 5 },
|
||||||
ReplaceWith { root: 0, m: 1 },
|
|
||||||
CreateElement { root: 7, tag: "h1" },
|
CreateElement { root: 7, tag: "h1" },
|
||||||
ReplaceWith { root: 1, m: 1 },
|
ReplaceWith { root: 1, m: 1 },
|
||||||
|
CreateElement { root: 8, tag: "h1" },
|
||||||
|
ReplaceWith { root: 2, m: 1 },
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -395,25 +395,21 @@ fn two_fragments_with_same_elements_are_differet() {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
create.edits,
|
create.edits,
|
||||||
[
|
[
|
||||||
CreateElement {
|
|
||||||
root: 0,
|
|
||||||
tag: "div"
|
|
||||||
},
|
|
||||||
CreateElement {
|
CreateElement {
|
||||||
root: 1,
|
root: 1,
|
||||||
tag: "div"
|
tag: "div"
|
||||||
},
|
},
|
||||||
CreateElement { root: 2, tag: "p" },
|
CreateElement {
|
||||||
|
root: 2,
|
||||||
|
tag: "div"
|
||||||
|
},
|
||||||
|
CreateElement { root: 3, tag: "p" },
|
||||||
AppendChildren { many: 3 },
|
AppendChildren { many: 3 },
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
change.edits,
|
change.edits,
|
||||||
[
|
[
|
||||||
CreateElement {
|
|
||||||
root: 3,
|
|
||||||
tag: "div"
|
|
||||||
},
|
|
||||||
CreateElement {
|
CreateElement {
|
||||||
root: 4,
|
root: 4,
|
||||||
tag: "div"
|
tag: "div"
|
||||||
|
@ -422,7 +418,11 @@ fn two_fragments_with_same_elements_are_differet() {
|
||||||
root: 5,
|
root: 5,
|
||||||
tag: "div"
|
tag: "div"
|
||||||
},
|
},
|
||||||
InsertAfter { root: 1, n: 3 },
|
CreateElement {
|
||||||
|
root: 6,
|
||||||
|
tag: "div"
|
||||||
|
},
|
||||||
|
InsertAfter { root: 2, n: 3 },
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -444,7 +444,7 @@ fn keyed_diffing_order() {
|
||||||
let (create, change) = dom.diff_lazynodes(left, right);
|
let (create, change) = dom.diff_lazynodes(left, right);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
change.edits,
|
change.edits,
|
||||||
[Remove { root: 2 }, Remove { root: 3 }, Remove { root: 4 },]
|
[Remove { root: 3 }, Remove { root: 4 }, Remove { root: 5 },]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -469,7 +469,7 @@ fn keyed_diffing_out_of_order() {
|
||||||
log::debug!("{:?}", &changes);
|
log::debug!("{:?}", &changes);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
changes.edits,
|
changes.edits,
|
||||||
[PushRoot { root: 6 }, InsertBefore { root: 4, n: 1 }]
|
[PushRoot { root: 7 }, InsertBefore { root: 5, n: 1 }]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -494,9 +494,9 @@ fn keyed_diffing_out_of_order_adds() {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
change.edits,
|
change.edits,
|
||||||
[
|
[
|
||||||
|
PushRoot { root: 5 },
|
||||||
PushRoot { root: 4 },
|
PushRoot { root: 4 },
|
||||||
PushRoot { root: 3 },
|
InsertBefore { n: 2, root: 1 }
|
||||||
InsertBefore { n: 2, root: 0 }
|
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -521,9 +521,9 @@ fn keyed_diffing_out_of_order_adds_2() {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
change.edits,
|
change.edits,
|
||||||
[
|
[
|
||||||
PushRoot { root: 3 },
|
|
||||||
PushRoot { root: 4 },
|
PushRoot { root: 4 },
|
||||||
InsertBefore { n: 2, root: 0 }
|
PushRoot { root: 5 },
|
||||||
|
InsertBefore { n: 2, root: 1 }
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -549,9 +549,9 @@ fn keyed_diffing_out_of_order_adds_3() {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
change.edits,
|
change.edits,
|
||||||
[
|
[
|
||||||
|
PushRoot { root: 5 },
|
||||||
PushRoot { root: 4 },
|
PushRoot { root: 4 },
|
||||||
PushRoot { root: 3 },
|
InsertBefore { n: 2, root: 2 }
|
||||||
InsertBefore { n: 2, root: 1 }
|
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -577,9 +577,9 @@ fn keyed_diffing_out_of_order_adds_4() {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
change.edits,
|
change.edits,
|
||||||
[
|
[
|
||||||
|
PushRoot { root: 5 },
|
||||||
PushRoot { root: 4 },
|
PushRoot { root: 4 },
|
||||||
PushRoot { root: 3 },
|
InsertBefore { n: 2, root: 3 }
|
||||||
InsertBefore { n: 2, root: 2 }
|
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -604,7 +604,7 @@ fn keyed_diffing_out_of_order_adds_5() {
|
||||||
let (_, change) = dom.diff_lazynodes(left, right);
|
let (_, change) = dom.diff_lazynodes(left, right);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
change.edits,
|
change.edits,
|
||||||
[PushRoot { root: 4 }, InsertBefore { n: 1, root: 3 }]
|
[PushRoot { root: 5 }, InsertBefore { n: 1, root: 4 }]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -628,15 +628,15 @@ fn keyed_diffing_additions() {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
change.edits,
|
change.edits,
|
||||||
[
|
[
|
||||||
CreateElement {
|
|
||||||
root: 5,
|
|
||||||
tag: "div"
|
|
||||||
},
|
|
||||||
CreateElement {
|
CreateElement {
|
||||||
root: 6,
|
root: 6,
|
||||||
tag: "div"
|
tag: "div"
|
||||||
},
|
},
|
||||||
InsertAfter { n: 2, root: 4 }
|
CreateElement {
|
||||||
|
root: 7,
|
||||||
|
tag: "div"
|
||||||
|
},
|
||||||
|
InsertAfter { n: 2, root: 5 }
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -665,16 +665,16 @@ fn keyed_diffing_additions_and_moves_on_ends() {
|
||||||
// create 11, 12
|
// create 11, 12
|
||||||
CreateElement {
|
CreateElement {
|
||||||
tag: "div",
|
tag: "div",
|
||||||
root: 4
|
root: 5
|
||||||
},
|
},
|
||||||
CreateElement {
|
CreateElement {
|
||||||
tag: "div",
|
tag: "div",
|
||||||
root: 5
|
root: 6
|
||||||
},
|
},
|
||||||
InsertAfter { root: 2, n: 2 },
|
InsertAfter { root: 3, n: 2 },
|
||||||
// move 7 to the front
|
// move 7 to the front
|
||||||
PushRoot { root: 3 },
|
PushRoot { root: 4 },
|
||||||
InsertBefore { root: 0, n: 1 }
|
InsertBefore { root: 1, n: 1 }
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -702,28 +702,28 @@ fn keyed_diffing_additions_and_moves_in_middle() {
|
||||||
change.edits,
|
change.edits,
|
||||||
[
|
[
|
||||||
// create 13, 17
|
// create 13, 17
|
||||||
CreateElement {
|
|
||||||
tag: "div",
|
|
||||||
root: 4
|
|
||||||
},
|
|
||||||
CreateElement {
|
CreateElement {
|
||||||
tag: "div",
|
tag: "div",
|
||||||
root: 5
|
root: 5
|
||||||
},
|
},
|
||||||
InsertBefore { root: 1, n: 2 },
|
|
||||||
// create 11, 12
|
|
||||||
CreateElement {
|
CreateElement {
|
||||||
tag: "div",
|
tag: "div",
|
||||||
root: 6
|
root: 6
|
||||||
},
|
},
|
||||||
|
InsertBefore { root: 2, n: 2 },
|
||||||
|
// create 11, 12
|
||||||
CreateElement {
|
CreateElement {
|
||||||
tag: "div",
|
tag: "div",
|
||||||
root: 7
|
root: 7
|
||||||
},
|
},
|
||||||
InsertBefore { root: 2, n: 2 },
|
CreateElement {
|
||||||
|
tag: "div",
|
||||||
|
root: 8
|
||||||
|
},
|
||||||
|
InsertBefore { root: 3, n: 2 },
|
||||||
// move 7
|
// move 7
|
||||||
PushRoot { root: 3 },
|
PushRoot { root: 4 },
|
||||||
InsertBefore { root: 0, n: 1 }
|
InsertBefore { root: 1, n: 1 }
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -751,22 +751,22 @@ fn controlled_keyed_diffing_out_of_order() {
|
||||||
changes.edits,
|
changes.edits,
|
||||||
[
|
[
|
||||||
// move 4 to after 6
|
// move 4 to after 6
|
||||||
PushRoot { root: 0 },
|
PushRoot { root: 1 },
|
||||||
InsertAfter { n: 1, root: 2 },
|
InsertAfter { n: 1, root: 3 },
|
||||||
// remove 7
|
// remove 7
|
||||||
|
|
||||||
// create 9 and insert before 6
|
// create 9 and insert before 6
|
||||||
CreateElement {
|
|
||||||
root: 4,
|
|
||||||
tag: "div"
|
|
||||||
},
|
|
||||||
InsertBefore { n: 1, root: 2 },
|
|
||||||
// create 0 and insert before 5
|
|
||||||
CreateElement {
|
CreateElement {
|
||||||
root: 5,
|
root: 5,
|
||||||
tag: "div"
|
tag: "div"
|
||||||
},
|
},
|
||||||
InsertBefore { n: 1, root: 1 },
|
InsertBefore { n: 1, root: 3 },
|
||||||
|
// create 0 and insert before 5
|
||||||
|
CreateElement {
|
||||||
|
root: 6,
|
||||||
|
tag: "div"
|
||||||
|
},
|
||||||
|
InsertBefore { n: 1, root: 2 },
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -793,12 +793,12 @@ fn controlled_keyed_diffing_out_of_order_max_test() {
|
||||||
changes.edits,
|
changes.edits,
|
||||||
[
|
[
|
||||||
CreateElement {
|
CreateElement {
|
||||||
root: 5,
|
root: 6,
|
||||||
tag: "div"
|
tag: "div"
|
||||||
},
|
},
|
||||||
InsertBefore { n: 1, root: 2 },
|
InsertBefore { n: 1, root: 3 },
|
||||||
PushRoot { root: 3 },
|
PushRoot { root: 4 },
|
||||||
InsertBefore { n: 1, root: 0 },
|
InsertBefore { n: 1, root: 1 },
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,25 +77,25 @@ fn events_generate() {
|
||||||
[
|
[
|
||||||
CreateElement {
|
CreateElement {
|
||||||
tag: "div",
|
tag: "div",
|
||||||
root: 0,
|
root: 1,
|
||||||
},
|
},
|
||||||
NewEventListener {
|
NewEventListener {
|
||||||
event_name: "click",
|
event_name: "click",
|
||||||
scope: ScopeId(0),
|
scope: ScopeId(0),
|
||||||
root: 0,
|
root: 1,
|
||||||
},
|
},
|
||||||
CreateElement {
|
CreateElement {
|
||||||
tag: "div",
|
tag: "div",
|
||||||
root: 1,
|
root: 2,
|
||||||
},
|
},
|
||||||
CreateTextNode {
|
CreateTextNode {
|
||||||
text: "nested",
|
text: "nested",
|
||||||
root: 2,
|
root: 3,
|
||||||
},
|
},
|
||||||
AppendChildren { many: 1 },
|
AppendChildren { many: 1 },
|
||||||
CreateTextNode {
|
CreateTextNode {
|
||||||
text: "Click me!",
|
text: "Click me!",
|
||||||
root: 3,
|
root: 4,
|
||||||
},
|
},
|
||||||
AppendChildren { many: 2 },
|
AppendChildren { many: 2 },
|
||||||
AppendChildren { many: 1 },
|
AppendChildren { many: 1 },
|
||||||
|
@ -123,7 +123,6 @@ fn components_generate() {
|
||||||
};
|
};
|
||||||
|
|
||||||
static Child: FC<()> = |cx, _| {
|
static Child: FC<()> = |cx, _| {
|
||||||
println!("running child");
|
|
||||||
cx.render(rsx! {
|
cx.render(rsx! {
|
||||||
h1 {}
|
h1 {}
|
||||||
})
|
})
|
||||||
|
@ -136,7 +135,7 @@ fn components_generate() {
|
||||||
[
|
[
|
||||||
CreateTextNode {
|
CreateTextNode {
|
||||||
text: "Text0",
|
text: "Text0",
|
||||||
root: 0,
|
root: 1,
|
||||||
},
|
},
|
||||||
AppendChildren { many: 1 },
|
AppendChildren { many: 1 },
|
||||||
]
|
]
|
||||||
|
@ -148,18 +147,6 @@ fn components_generate() {
|
||||||
[
|
[
|
||||||
CreateElement {
|
CreateElement {
|
||||||
tag: "div",
|
tag: "div",
|
||||||
root: 1,
|
|
||||||
},
|
|
||||||
ReplaceWith { root: 0, m: 1 },
|
|
||||||
]
|
|
||||||
);
|
|
||||||
|
|
||||||
let edits = dom.hard_diff(&ScopeId(0)).unwrap();
|
|
||||||
assert_eq!(
|
|
||||||
edits.edits,
|
|
||||||
[
|
|
||||||
CreateTextNode {
|
|
||||||
text: "Text2",
|
|
||||||
root: 2,
|
root: 2,
|
||||||
},
|
},
|
||||||
ReplaceWith { root: 1, m: 1 },
|
ReplaceWith { root: 1, m: 1 },
|
||||||
|
@ -170,7 +157,10 @@ fn components_generate() {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
edits.edits,
|
edits.edits,
|
||||||
[
|
[
|
||||||
CreateElement { tag: "h1", root: 3 },
|
CreateTextNode {
|
||||||
|
text: "Text2",
|
||||||
|
root: 3,
|
||||||
|
},
|
||||||
ReplaceWith { root: 2, m: 1 },
|
ReplaceWith { root: 2, m: 1 },
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
@ -178,7 +168,16 @@ fn components_generate() {
|
||||||
let edits = dom.hard_diff(&ScopeId(0)).unwrap();
|
let edits = dom.hard_diff(&ScopeId(0)).unwrap();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
edits.edits,
|
edits.edits,
|
||||||
[CreatePlaceholder { root: 4 }, ReplaceWith { root: 3, m: 1 },]
|
[
|
||||||
|
CreateElement { tag: "h1", root: 4 },
|
||||||
|
ReplaceWith { root: 3, m: 1 },
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
let edits = dom.hard_diff(&ScopeId(0)).unwrap();
|
||||||
|
assert_eq!(
|
||||||
|
edits.edits,
|
||||||
|
[CreatePlaceholder { root: 5 }, ReplaceWith { root: 4, m: 1 },]
|
||||||
);
|
);
|
||||||
|
|
||||||
let edits = dom.hard_diff(&ScopeId(0)).unwrap();
|
let edits = dom.hard_diff(&ScopeId(0)).unwrap();
|
||||||
|
@ -187,9 +186,9 @@ fn components_generate() {
|
||||||
[
|
[
|
||||||
CreateTextNode {
|
CreateTextNode {
|
||||||
text: "text 3",
|
text: "text 3",
|
||||||
root: 5,
|
root: 6,
|
||||||
},
|
},
|
||||||
ReplaceWith { root: 4, m: 1 },
|
ReplaceWith { root: 5, m: 1 },
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -199,13 +198,13 @@ fn components_generate() {
|
||||||
[
|
[
|
||||||
CreateTextNode {
|
CreateTextNode {
|
||||||
text: "text 0",
|
text: "text 0",
|
||||||
root: 6,
|
root: 7,
|
||||||
},
|
},
|
||||||
CreateTextNode {
|
CreateTextNode {
|
||||||
text: "text 1",
|
text: "text 1",
|
||||||
root: 7,
|
root: 8,
|
||||||
},
|
},
|
||||||
ReplaceWith { root: 5, m: 2 },
|
ReplaceWith { root: 6, m: 2 },
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -213,9 +212,9 @@ fn components_generate() {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
edits.edits,
|
edits.edits,
|
||||||
[
|
[
|
||||||
CreateElement { tag: "h1", root: 8 },
|
CreateElement { tag: "h1", root: 9 },
|
||||||
ReplaceWith { root: 6, m: 1 },
|
ReplaceWith { root: 7, m: 1 },
|
||||||
Remove { root: 7 },
|
Remove { root: 8 },
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ fn shared_state_test() {
|
||||||
edits,
|
edits,
|
||||||
[
|
[
|
||||||
CreateTextNode {
|
CreateTextNode {
|
||||||
root: 0,
|
root: 1,
|
||||||
text: "Hello, world!"
|
text: "Hello, world!"
|
||||||
},
|
},
|
||||||
AppendChildren { many: 1 },
|
AppendChildren { many: 1 },
|
||||||
|
|
Loading…
Reference in a new issue