fix web onmount event
This commit is contained in:
1 parent
d06e64e5ad
commit
3a02520ffa
2 files changed
+10
-7
No files matched your search
@@ -253,8 +253,7 @@ impl WebsysDom {
|
|||||||
let node = dioxus_interpreter_js::get_node(id.0 as u32);
|
let node = dioxus_interpreter_js::get_node(id.0 as u32);
|
||||||
if let Some(element) = node.dyn_ref::<Element>() {
|
if let Some(element) = node.dyn_ref::<Element>() {
|
||||||
log::info!("mounted event fired: {}", id.0);
|
log::info!("mounted event fired: {}", id.0);
|
||||||
let data: dioxus_html::MountedData = element.into();
|
let data = PlatformEventData::new(Box::new(element.clone()));
|
||||||
let data = PlatformEventData::new(Box::new(data));
|
|
||||||
let _ = self.event_channel.unbounded_send(UiEvent {
|
let _ = self.event_channel.unbounded_send(UiEvent {
|
||||||
name: "mounted".to_string(),
|
name: "mounted".to_string(),
|
||||||
bubbles: false,
|
bubbles: false,
|
||||||
|
|||||||
@@ -83,7 +83,11 @@ impl HtmlEventConverter for WebEventConverter {
|
|||||||
fn convert_mounted_data(&self, event: &dioxus_html::PlatformEventData) -> MountedData {
|
fn convert_mounted_data(&self, event: &dioxus_html::PlatformEventData) -> MountedData {
|
||||||
#[cfg(feature = "mounted")]
|
#[cfg(feature = "mounted")]
|
||||||
{
|
{
|
||||||
MountedData::from(downcast_event(event).element.clone())
|
MountedData::from(
|
||||||
|
event
|
||||||
|
.downcast::<web_sys::Element>()
|
||||||
|
.expect("event should be a web_sys::Element"),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
#[cfg(not(feature = "mounted"))]
|
#[cfg(not(feature = "mounted"))]
|
||||||
{
|
{
|
||||||
@@ -216,10 +220,10 @@ impl WebEventExt<web_sys::Event> for dioxus_html::MediaData {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WebEventExt<MountedData> for MountedData {
|
impl WebEventExt<web_sys::Element> for MountedData {
|
||||||
fn web_event(&self) -> &MountedData {
|
fn web_event(&self) -> &web_sys::Element {
|
||||||
self.downcast::<MountedData>()
|
self.downcast::<web_sys::Element>()
|
||||||
.expect("event should be a WebMountedEvent")
|
.expect("event should be a web_sys::Element")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user