Send mount event when hydrating (#1764)
This commit is contained in:
1 parent
3733fbf47d
commit
0166eafafb
2 files changed
+14
-1
No files matched your search
@@ -256,6 +256,11 @@ impl WebsysDom {
|
||||
i.flush();
|
||||
|
||||
for id in to_mount {
|
||||
self.send_mount_event(id);
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn send_mount_event(&self, id: ElementId) {
|
||||
let node = get_node(id.0 as u32);
|
||||
if let Some(element) = node.dyn_ref::<Element>() {
|
||||
let data: MountedData = element.into();
|
||||
@@ -269,7 +274,6 @@ impl WebsysDom {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// todo: some of these events are being casted to the wrong event type.
|
||||
// We need tests that simulate clicks/etc and make sure every event type works.
|
||||
|
||||
@@ -125,6 +125,7 @@ impl WebsysDom {
|
||||
children, attrs, ..
|
||||
} => {
|
||||
let mut mounted_id = None;
|
||||
let mut should_send_mount_event = true;
|
||||
for attr in *attrs {
|
||||
if let dioxus_core::TemplateAttribute::Dynamic { id } = attr {
|
||||
let attribute = &vnode.dynamic_attrs[*id];
|
||||
@@ -134,6 +135,9 @@ impl WebsysDom {
|
||||
let name = attribute.name;
|
||||
if let AttributeValue::Listener(_) = value {
|
||||
let event_name = &name[2..];
|
||||
match event_name {
|
||||
"mounted" => should_send_mount_event = true,
|
||||
_ => {
|
||||
self.interpreter.new_event_listener(
|
||||
event_name,
|
||||
id.0 as u32,
|
||||
@@ -142,8 +146,13 @@ impl WebsysDom {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if let Some(id) = mounted_id {
|
||||
set_node(hydrated, id, current_child.clone()?);
|
||||
if should_send_mount_event {
|
||||
self.send_mount_event(id);
|
||||
}
|
||||
}
|
||||
if !children.is_empty() {
|
||||
let mut children_current_child = current_child
|
||||
|
||||
Reference in new issue
Block a user