get compiling

This commit is contained in:
Jonathan Kelley committed 2024-01-11 16:51:18 -08:00
1 parent 2ae3241cc0
commit 8c94f0bc4a
18 files changed
+325 -344

No files matched your search

+37 -62
View File
@@ -338,6 +338,7 @@ impl VirtualDom {
/// It is up to the listeners themselves to mark nodes as dirty.
///
/// If you have multiple events, you can call this method multiple times before calling "render_with_deadline"
pub fn handle_event(
&mut self,
name: &str,
@@ -394,14 +395,17 @@ impl VirtualDom {
let this_path = node_template.attr_paths[idx];
// Remove the "on" prefix if it exists, TODO, we should remove this and settle on one
if target_path.is_decendant(&this_path) {
attr.ty.for_each(|attribute| {
if attribute.name.trim_start_matches("on") == name {
if let AttributeValue::Listener(listener) = &attribute.value {
listeners.push(listener);
}
}
});
if attr.name.trim_start_matches("on") == name
&& target_path.is_decendant(&this_path)
{
listeners.push(&attr.value);
// Break if this is the exact target element.
// This means we won't call two listeners with the same name on the same element. This should be
// documented, or be rejected from the rsx! macro outright
if target_path == this_path {
break;
}
}
}
@@ -413,67 +417,38 @@ impl VirtualDom {
listener.call(uievent.clone());
self.runtime.rendering.set(true);
// let origin: ScopeId = path.scope;
// self.runtime.scope_stack.borrow_mut().push(origin);
// self.runtime.rendering.set(false);
// if let Some(cb) = listener.borrow_mut().as_deref_mut() {
// cb(uievent.clone());
// }
// self.runtime.scope_stack.borrow_mut().pop();
// self.runtime.rendering.set(true);
if !uievent.propagates.get() {
return;
}
}
}
let mount = el_ref.mount.get().as_usize();
parent_node = mount.and_then(|id| self.mounts.get(id).and_then(|el| el.parent));
let mount = el_ref.mount.get().as_usize();
parent_node = mount.and_then(|id| self.mounts.get(id).and_then(|el| el.parent));
}
} else {
// Otherwise, we just call the listener on the target element
if let Some(path) = parent_node {
let el_ref = &self.mounts[path.mount.0].node;
let node_template = el_ref.template.get();
let target_path = path.path;
for (idx, attr) in el_ref.dynamic_attrs.iter().enumerate() {
let this_path = node_template.attr_paths[idx];
// Remove the "on" prefix if it exists, TODO, we should remove this and settle on one
// Only call the listener if this is the exact target element.
if attr.name.trim_start_matches("on") == name && target_path == this_path {
if let AttributeValue::Listener(listener) = &attr.value {
self.runtime.rendering.set(false);
listener.call(uievent.clone());
self.runtime.rendering.set(true);
break;
}
}
}
}
// else {
// // Otherwise, we just call the listener on the target element
// if let Some(path) = parent_node {
// let el_ref = &self.mounts[path.mount.0].node;
// let node_template = el_ref.template.get();
// let target_path = path.path;
// for (idx, attr) in el_ref.dynamic_attrs.iter().enumerate() {
// let this_path = node_template.attr_paths[idx];
// // Remove the "on" prefix if it exists, TODO, we should remove this and settle on one
// // Only call the listener if this is the exact target element.
// if attr.name.trim_start_matches("on") == name && target_path == this_path {
// if let AttributeValue::Listener(listener) = &attr.value {
// self.runtime.rendering.set(false);
// listener.call(uievent.clone());
// self.runtime.rendering.set(true);
// // if target_path == this_path {
// // let mut should_stop = false;
// // attr.ty.for_each(|attribute| {
// // if attribute.name.trim_start_matches("on") == name {
// // if let AttributeValue::Listener(listener) = &attribute.value {
// // let origin = path.scope;
// // self.runtime.scope_stack.borrow_mut().push(origin);
// // self.runtime.rendering.set(false);
// // if let Some(cb) = listener.borrow_mut().as_deref_mut() {
// // cb(uievent.clone());
// // }
// // self.runtime.scope_stack.borrow_mut().pop();
// // self.runtime.rendering.set(true);
// should_stop = true;
// }
// }
// // });
// if should_stop {
// return;
// }
// }
// }
// }
}
}