fix events triggering on placeholders causing panics

This commit is contained in:
Evan Almloff committed 2023-06-02 14:21:49 -05:00
1 parent 563a2b0953
commit 9d5f115e30
1 file changed
+9 -3
+9 -3
View File
@@ -389,7 +389,8 @@ impl VirtualDom {
// Loop through each dynamic attribute (in a depth first order) in this template before moving up to the template's parent. // Loop through each dynamic attribute (in a depth first order) in this template before moving up to the template's parent.
while let Some(el_ref) = parent_path { while let Some(el_ref) = parent_path {
// safety: we maintain references of all vnodes in the element slab // safety: we maintain references of all vnodes in the element slab
let template = unsafe { el_ref.template.unwrap().as_ref() }; if let Some(template) = el_ref.template {
let template = unsafe { template.as_ref() };
let node_template = template.template.get(); let node_template = template.template.get();
let target_path = el_ref.path; let target_path = el_ref.path;
@@ -425,13 +426,17 @@ impl VirtualDom {
} }
} }
parent_path = template.parent.and_then(|id| self.elements.get(id.0)); parent_path = dbg!(template.parent).and_then(|id| self.elements.get(id.0));
} else {
break;
}
} }
} else { } else {
// Otherwise, we just call the listener on the target element // Otherwise, we just call the listener on the target element
if let Some(el_ref) = parent_path { if let Some(el_ref) = parent_path {
// safety: we maintain references of all vnodes in the element slab // safety: we maintain references of all vnodes in the element slab
let template = unsafe { el_ref.template.unwrap().as_ref() }; if let Some(template) = el_ref.template {
let template = unsafe { template.as_ref() };
let node_template = template.template.get(); let node_template = template.template.get();
let target_path = el_ref.path; let target_path = el_ref.path;
@@ -453,6 +458,7 @@ impl VirtualDom {
} }
} }
} }
}
/// Wait for the scheduler to have any work. /// Wait for the scheduler to have any work.
/// ///