feat: fix the scope rollover bug
This commit is contained in:
1 parent
e4d089fabc
commit
d4b6bb8a7b
17 files changed
+591
-360
No files matched your search
+1
-30
@@ -218,13 +218,7 @@ pub async fn run_with_props<T: 'static>(root: fn(Scope<T>) -> Element, root_prop
|
||||
// Dequeue all of the events from the channel in send order
|
||||
// todo: we should re-order these if possible
|
||||
while let Some(evt) = res {
|
||||
let name = evt.type_();
|
||||
let element = walk_event_for_id(&evt);
|
||||
let bubbles = dioxus_html::event_bubbles(name.as_str());
|
||||
if let Some((element, target)) = element {
|
||||
let data = virtual_event_from_websys_event(evt, target);
|
||||
dom.handle_event(name.as_str(), data, element, bubbles);
|
||||
}
|
||||
dom.handle_event(evt.name.as_str(), evt.data, evt.element, evt.bubbles);
|
||||
res = rx.try_next().transpose().unwrap().ok();
|
||||
}
|
||||
|
||||
@@ -250,29 +244,6 @@ pub async fn run_with_props<T: 'static>(root: fn(Scope<T>) -> Element, root_prop
|
||||
}
|
||||
}
|
||||
|
||||
fn walk_event_for_id(event: &web_sys::Event) -> Option<(ElementId, web_sys::Element)> {
|
||||
use wasm_bindgen::JsCast;
|
||||
|
||||
let mut target = event
|
||||
.target()
|
||||
.expect("missing target")
|
||||
.dyn_into::<web_sys::Element>()
|
||||
.expect("not a valid element");
|
||||
|
||||
loop {
|
||||
match target.get_attribute("data-dioxus-id").map(|f| f.parse()) {
|
||||
Some(Ok(id)) => return Some((ElementId(id), target)),
|
||||
Some(Err(_)) => return None,
|
||||
|
||||
// walk the tree upwards until we actually find an event target
|
||||
None => match target.parent_element() {
|
||||
Some(parent) => target = parent,
|
||||
None => return None,
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if should_hydrate {
|
||||
// // todo: we need to split rebuild and initialize into two phases
|
||||
// // it's a waste to produce edits just to get the vdom loaded
|
||||
|
||||
Reference in new issue
Block a user