wip: lots of changes to diffing
This commit is contained in:
1 parent
56e7eb83a9
commit
ff0a3d1c83
24 files changed
+617
-672
No files matched your search
@@ -19,12 +19,6 @@ impl<'a> RealChildIterator<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
// impl<'a> DoubleEndedIterator for ChildIterator<'a> {
|
||||
// fn next_back(&mut self) -> Option<Self::Item> {
|
||||
// todo!()
|
||||
// }
|
||||
// }
|
||||
|
||||
impl<'a> Iterator for RealChildIterator<'a> {
|
||||
type Item = &'a VNode<'a>;
|
||||
|
||||
@@ -37,6 +31,7 @@ impl<'a> Iterator for RealChildIterator<'a> {
|
||||
if let Some((count, node)) = self.stack.last_mut() {
|
||||
match node {
|
||||
// We can only exit our looping when we get "real" nodes
|
||||
// This includes fragments and components when they're empty (have a single root)
|
||||
VNode::Element(_) | VNode::Text(_) => {
|
||||
// We've recursed INTO an element/text
|
||||
// We need to recurse *out* of it and move forward to the next
|
||||
@@ -46,11 +41,17 @@ impl<'a> Iterator for RealChildIterator<'a> {
|
||||
|
||||
// If we get a fragment we push the next child
|
||||
VNode::Fragment(frag) => {
|
||||
let _count = *count as usize;
|
||||
if _count >= frag.children.len() {
|
||||
let subcount = *count as usize;
|
||||
|
||||
if frag.children.len() == 0 {
|
||||
should_pop = true;
|
||||
returned_node = Some(&**node);
|
||||
}
|
||||
|
||||
if subcount >= frag.children.len() {
|
||||
should_pop = true;
|
||||
} else {
|
||||
should_push = Some(&frag.children[_count]);
|
||||
should_push = Some(&frag.children[subcount]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,77 +89,3 @@ impl<'a> Iterator for RealChildIterator<'a> {
|
||||
returned_node
|
||||
}
|
||||
}
|
||||
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate as dioxus;
|
||||
use crate::innerlude::*;
|
||||
use crate::util::DebugDom;
|
||||
use dioxus_core_macro::*;
|
||||
|
||||
// #[test]
|
||||
// fn test_child_iterator() {
|
||||
// static App: FC<()> = |cx| {
|
||||
// cx.render(rsx! {
|
||||
// Fragment {
|
||||
// div {}
|
||||
// h1 {}
|
||||
// h2 {}
|
||||
// h3 {}
|
||||
// Fragment {
|
||||
// "internal node"
|
||||
// div {
|
||||
// "baller text shouldn't show up"
|
||||
// }
|
||||
// p {
|
||||
|
||||
// }
|
||||
// Fragment {
|
||||
// Fragment {
|
||||
// "wow you really like framgents"
|
||||
// Fragment {
|
||||
// "why are you like this"
|
||||
// Fragment {
|
||||
// "just stop now please"
|
||||
// Fragment {
|
||||
// "this hurts"
|
||||
// Fragment {
|
||||
// "who needs this many fragments?????"
|
||||
// Fragment {
|
||||
// "just... fine..."
|
||||
// Fragment {
|
||||
// "no"
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// "my text node 1"
|
||||
// "my text node 2"
|
||||
// "my text node 3"
|
||||
// "my text node 4"
|
||||
// }
|
||||
// })
|
||||
// };
|
||||
// let mut dom = VirtualDom::new(App);
|
||||
// let mut renderer = DebugDom::new();
|
||||
// dom.rebuild(&mut renderer).unwrap();
|
||||
// let starter = dom.base_scope().root();
|
||||
// let ite = RealChildIterator::new(starter, &dom.components);
|
||||
// for child in ite {
|
||||
// match child {
|
||||
// VNode::Element(el) => println!("Found: Element {}", el.tag_name),
|
||||
// VNode::Text(t) => println!("Found: Text {:?}", t.text),
|
||||
|
||||
// // These would represent failing cases.
|
||||
// VNode::Fragment(_) => panic!("Found: Fragment"),
|
||||
// VNode::Suspended { real } => panic!("Found: Suspended"),
|
||||
// VNode::Component(_) => panic!("Found: Component"),
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
Reference in new issue
Block a user