Merge pull request #1010 from Demonthos/fix-onload-event
Fix the onload event
This commit is contained in:
6 files changed
+15
-8
No files matched your search
@@ -129,6 +129,7 @@ pub fn event_bubbles(evt: &str) -> bool {
|
|||||||
"loadeddata" => false,
|
"loadeddata" => false,
|
||||||
"loadedmetadata" => false,
|
"loadedmetadata" => false,
|
||||||
"loadstart" => false,
|
"loadstart" => false,
|
||||||
|
"load" => false,
|
||||||
"pause" => false,
|
"pause" => false,
|
||||||
"play" => false,
|
"play" => false,
|
||||||
"playing" => false,
|
"playing" => false,
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ pub type ImageEvent = Event<ImageData>;
|
|||||||
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
|
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
pub struct ImageData {
|
pub struct ImageData {
|
||||||
|
#[cfg_attr(feature = "serialize", serde(default))]
|
||||||
pub load_error: bool,
|
pub load_error: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ use keyboard_types::Location;
|
|||||||
|
|
||||||
/// A mouse button type (such as Primary/Secondary)
|
/// A mouse button type (such as Primary/Secondary)
|
||||||
// note: EnumSetType also derives Copy and Clone for some reason
|
// note: EnumSetType also derives Copy and Clone for some reason
|
||||||
|
#[allow(clippy::unused_unit)]
|
||||||
#[derive(EnumSetType, Debug)]
|
#[derive(EnumSetType, Debug)]
|
||||||
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
|
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
|
||||||
pub enum MouseButton {
|
pub enum MouseButton {
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ fn fun_name(
|
|||||||
// Touch
|
// Touch
|
||||||
"touchcancel" | "touchend" | "touchmove" | "touchstart" => Touch(de(data)?),
|
"touchcancel" | "touchend" | "touchmove" | "touchstart" => Touch(de(data)?),
|
||||||
|
|
||||||
// Srcoll
|
// Scroll
|
||||||
"scroll" => Scroll(de(data)?),
|
"scroll" => Scroll(de(data)?),
|
||||||
|
|
||||||
// Wheel
|
// Wheel
|
||||||
@@ -102,7 +102,7 @@ fn fun_name(
|
|||||||
| "ended" | "interruptbegin" | "interruptend" | "loadeddata" | "loadedmetadata"
|
| "ended" | "interruptbegin" | "interruptend" | "loadeddata" | "loadedmetadata"
|
||||||
| "loadstart" | "pause" | "play" | "playing" | "progress" | "ratechange" | "seeked"
|
| "loadstart" | "pause" | "play" | "playing" | "progress" | "ratechange" | "seeked"
|
||||||
| "seeking" | "stalled" | "suspend" | "timeupdate" | "volumechange" | "waiting"
|
| "seeking" | "stalled" | "suspend" | "timeupdate" | "volumechange" | "waiting"
|
||||||
| "error" | "load" | "loadend" | "timeout" => Media(de(data)?),
|
| "loadend" | "timeout" => Media(de(data)?),
|
||||||
|
|
||||||
// Animation
|
// Animation
|
||||||
"animationstart" | "animationend" | "animationiteration" => Animation(de(data)?),
|
"animationstart" | "animationend" | "animationiteration" => Animation(de(data)?),
|
||||||
@@ -113,10 +113,11 @@ fn fun_name(
|
|||||||
// Toggle
|
// Toggle
|
||||||
"toggle" => Toggle(de(data)?),
|
"toggle" => Toggle(de(data)?),
|
||||||
|
|
||||||
|
"load" | "error" => Image(de(data)?),
|
||||||
|
|
||||||
// Mounted
|
// Mounted
|
||||||
"mounted" => Mounted,
|
"mounted" => Mounted,
|
||||||
|
|
||||||
// ImageData => "load" | "error";
|
|
||||||
// OtherData => "abort" | "afterprint" | "beforeprint" | "beforeunload" | "hashchange" | "languagechange" | "message" | "offline" | "online" | "pagehide" | "pageshow" | "popstate" | "rejectionhandled" | "storage" | "unhandledrejection" | "unload" | "userproximity" | "vrdisplayactivate" | "vrdisplayblur" | "vrdisplayconnect" | "vrdisplaydeactivate" | "vrdisplaydisconnect" | "vrdisplayfocus" | "vrdisplaypointerrestricted" | "vrdisplaypointerunrestricted" | "vrdisplaypresentchange";
|
// OtherData => "abort" | "afterprint" | "beforeprint" | "beforeunload" | "hashchange" | "languagechange" | "message" | "offline" | "online" | "pagehide" | "pageshow" | "popstate" | "rejectionhandled" | "storage" | "unhandledrejection" | "unload" | "userproximity" | "vrdisplayactivate" | "vrdisplayblur" | "vrdisplayconnect" | "vrdisplaydeactivate" | "vrdisplaydisconnect" | "vrdisplayfocus" | "vrdisplaypointerrestricted" | "vrdisplaypointerunrestricted" | "vrdisplaypresentchange";
|
||||||
other => {
|
other => {
|
||||||
return Err(serde_value::DeserializerError::UnknownVariant(
|
return Err(serde_value::DeserializerError::UnknownVariant(
|
||||||
@@ -137,6 +138,7 @@ impl HtmlEvent {
|
|||||||
|
|
||||||
#[derive(Deserialize, Serialize, Debug, Clone, PartialEq)]
|
#[derive(Deserialize, Serialize, Debug, Clone, PartialEq)]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
|
#[non_exhaustive]
|
||||||
pub enum EventData {
|
pub enum EventData {
|
||||||
Mouse(MouseData),
|
Mouse(MouseData),
|
||||||
Clipboard(ClipboardData),
|
Clipboard(ClipboardData),
|
||||||
@@ -154,6 +156,7 @@ pub enum EventData {
|
|||||||
Animation(AnimationData),
|
Animation(AnimationData),
|
||||||
Transition(TransitionData),
|
Transition(TransitionData),
|
||||||
Toggle(ToggleData),
|
Toggle(ToggleData),
|
||||||
|
Image(ImageData),
|
||||||
Mounted,
|
Mounted,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -176,6 +179,7 @@ impl EventData {
|
|||||||
EventData::Animation(data) => Rc::new(data) as Rc<dyn Any>,
|
EventData::Animation(data) => Rc::new(data) as Rc<dyn Any>,
|
||||||
EventData::Transition(data) => Rc::new(data) as Rc<dyn Any>,
|
EventData::Transition(data) => Rc::new(data) as Rc<dyn Any>,
|
||||||
EventData::Toggle(data) => Rc::new(data) as Rc<dyn Any>,
|
EventData::Toggle(data) => Rc::new(data) as Rc<dyn Any>,
|
||||||
|
EventData::Image(data) => Rc::new(data) as Rc<dyn Any>,
|
||||||
EventData::Mounted => Rc::new(MountedData::new(())) as Rc<dyn Any>,
|
EventData::Mounted => Rc::new(MountedData::new(())) as Rc<dyn Any>,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -892,10 +892,9 @@ function event_bubbles(event) {
|
|||||||
case "error":
|
case "error":
|
||||||
return false;
|
return false;
|
||||||
case "loadeddata":
|
case "loadeddata":
|
||||||
return false;
|
|
||||||
case "loadedmetadata":
|
case "loadedmetadata":
|
||||||
return false;
|
|
||||||
case "loadstart":
|
case "loadstart":
|
||||||
|
case "load":
|
||||||
return false;
|
return false;
|
||||||
case "pause":
|
case "pause":
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ use js_sys::Array;
|
|||||||
use rustc_hash::FxHashMap;
|
use rustc_hash::FxHashMap;
|
||||||
use std::{any::Any, rc::Rc, sync::Arc};
|
use std::{any::Any, rc::Rc, sync::Arc};
|
||||||
use wasm_bindgen::{closure::Closure, prelude::wasm_bindgen, JsCast, JsValue};
|
use wasm_bindgen::{closure::Closure, prelude::wasm_bindgen, JsCast, JsValue};
|
||||||
use web_sys::{console, Document, Element, Event};
|
use web_sys::{Document, Element, Event};
|
||||||
|
|
||||||
use crate::{file_engine::WebFileEngine, Config};
|
use crate::{file_engine::WebFileEngine, Config};
|
||||||
|
|
||||||
@@ -257,7 +257,6 @@ impl WebsysDom {
|
|||||||
// We need tests that simulate clicks/etc and make sure every event type works.
|
// We need tests that simulate clicks/etc and make sure every event type works.
|
||||||
pub fn virtual_event_from_websys_event(event: web_sys::Event, target: Element) -> Rc<dyn Any> {
|
pub fn virtual_event_from_websys_event(event: web_sys::Event, target: Element) -> Rc<dyn Any> {
|
||||||
use dioxus_html::events::*;
|
use dioxus_html::events::*;
|
||||||
console::log_1(&event.clone().into());
|
|
||||||
|
|
||||||
match event.type_().as_str() {
|
match event.type_().as_str() {
|
||||||
"copy" | "cut" | "paste" => Rc::new(ClipboardData {}),
|
"copy" | "cut" | "paste" => Rc::new(ClipboardData {}),
|
||||||
@@ -293,9 +292,11 @@ pub fn virtual_event_from_websys_event(event: web_sys::Event, target: Element) -
|
|||||||
}
|
}
|
||||||
"transitionend" => Rc::new(TransitionData::from(event)),
|
"transitionend" => Rc::new(TransitionData::from(event)),
|
||||||
"abort" | "canplay" | "canplaythrough" | "durationchange" | "emptied" | "encrypted"
|
"abort" | "canplay" | "canplaythrough" | "durationchange" | "emptied" | "encrypted"
|
||||||
| "ended" | "error" | "loadeddata" | "loadedmetadata" | "loadstart" | "pause" | "play"
|
| "ended" | "loadeddata" | "loadedmetadata" | "loadstart" | "pause" | "play"
|
||||||
| "playing" | "progress" | "ratechange" | "seeked" | "seeking" | "stalled" | "suspend"
|
| "playing" | "progress" | "ratechange" | "seeked" | "seeking" | "stalled" | "suspend"
|
||||||
| "timeupdate" | "volumechange" | "waiting" => Rc::new(MediaData {}),
|
| "timeupdate" | "volumechange" | "waiting" => Rc::new(MediaData {}),
|
||||||
|
"error" => Rc::new(ImageData { load_error: true }),
|
||||||
|
"load" => Rc::new(ImageData { load_error: false }),
|
||||||
"toggle" => Rc::new(ToggleData {}),
|
"toggle" => Rc::new(ToggleData {}),
|
||||||
|
|
||||||
_ => Rc::new(()),
|
_ => Rc::new(()),
|
||||||
|
|||||||
Reference in new issue
Block a user