mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-09-20 14:21:58 +00:00
assign parents through fragments
This commit is contained in:
parent
35b643e23f
commit
d81d3ebaef
4 changed files with 13 additions and 6 deletions
|
@ -485,7 +485,7 @@ impl<'b> VirtualDom {
|
|||
Text(text) => self.create_dynamic_text(parent, text),
|
||||
Placeholder(place) => self.create_placeholder(place, parent),
|
||||
Component(component) => self.create_component_node(Some(parent), component),
|
||||
Fragment(frag) => frag.iter().map(|child| self.create(child)).sum(),
|
||||
Fragment(frag) => self.create_children(*frag, Some(parent)),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -776,15 +776,18 @@ impl<'b> VirtualDom {
|
|||
.sum()
|
||||
}
|
||||
|
||||
fn create_children(
|
||||
pub(crate) fn create_children(
|
||||
&mut self,
|
||||
nodes: impl IntoIterator<Item = &'b VNode<'b>>,
|
||||
parent: Option<ElementRef>,
|
||||
) -> usize {
|
||||
nodes.into_iter().fold(0, |acc, child| {
|
||||
self.assign_boundary_ref(parent, child);
|
||||
acc + self.create(child)
|
||||
})
|
||||
nodes
|
||||
.into_iter()
|
||||
.map(|child| {
|
||||
self.assign_boundary_ref(parent, child);
|
||||
self.create(child)
|
||||
})
|
||||
.sum()
|
||||
}
|
||||
|
||||
fn create_and_insert_before(
|
||||
|
|
|
@ -379,9 +379,11 @@ impl VirtualDom {
|
|||
let template = unsafe { el_ref.unwrap().as_ref() };
|
||||
let node_template = template.template.get();
|
||||
let target_path = path.path;
|
||||
println!("handle_event: {:?} ({:?})", target_path, template);
|
||||
|
||||
for (idx, attr) in template.dynamic_attrs.iter().enumerate() {
|
||||
let this_path = node_template.attr_paths[idx];
|
||||
println!("checking: {:?} ({:?})", this_path, attr);
|
||||
|
||||
// Remove the "on" prefix if it exists, TODO, we should remove this and settle on one
|
||||
if attr.name.trim_start_matches("on") == name
|
||||
|
@ -401,6 +403,7 @@ impl VirtualDom {
|
|||
// Now that we've accumulated all the parent attributes for the target element, call them in reverse order
|
||||
// We check the bubble state between each call to see if the event has been stopped from bubbling
|
||||
for listener in listeners.drain(..).rev() {
|
||||
println!("handle_event: {:?}", listener);
|
||||
if let AttributeValue::Listener(listener) = listener {
|
||||
let origin = path.scope;
|
||||
self.runtime.scope_stack.borrow_mut().push(origin);
|
||||
|
|
|
@ -55,6 +55,7 @@ fn problematic_child(cx: Scope) -> Element {
|
|||
render! {
|
||||
button {
|
||||
onclick: move |evt| {
|
||||
println!("bottom clicked");
|
||||
let mut clicks = CLICKS.lock().unwrap();
|
||||
|
||||
if *clicks == 3 {
|
||||
|
|
Loading…
Reference in a new issue