fix the onload event

This commit is contained in:
Evan Almloff committed 2023-05-08 17:49:28 -05:00
1 parent b6463e4b27
commit 043aae1689
5 files changed
+14 -9

No files matched your search

+1
View File
@@ -127,6 +127,7 @@ pub fn event_bubbles(evt: &str) -> bool {
"loadeddata" => false,
"loadedmetadata" => false,
"loadstart" => false,
"load" => false,
"pause" => false,
"play" => false,
"playing" => false,
+1
View File
@@ -4,6 +4,7 @@ pub type ImageEvent = Event<ImageData>;
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ImageData {
#[cfg_attr(feature = "serialize", serde(default))]
pub load_error: bool,
}
+7 -3
View File
@@ -91,7 +91,7 @@ fn fun_name(
// Touch
"touchcancel" | "touchend" | "touchmove" | "touchstart" => Touch(de(data)?),
// Srcoll
// Scroll
"scroll" => Scroll(de(data)?),
// Wheel
@@ -102,7 +102,7 @@ fn fun_name(
| "ended" | "interruptbegin" | "interruptend" | "loadeddata" | "loadedmetadata"
| "loadstart" | "pause" | "play" | "playing" | "progress" | "ratechange" | "seeked"
| "seeking" | "stalled" | "suspend" | "timeupdate" | "volumechange" | "waiting"
| "error" | "load" | "loadend" | "timeout" => Media(de(data)?),
| "loadend" | "timeout" => Media(de(data)?),
// Animation
"animationstart" | "animationend" | "animationiteration" => Animation(de(data)?),
@@ -113,7 +113,8 @@ fn fun_name(
// Toggle
"toggle" => Toggle(de(data)?),
// ImageData => "load" | "error";
"load" | "error" => Image(de(data)?),
// 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 => {
return Err(serde_value::DeserializerError::UnknownVariant(
@@ -134,6 +135,7 @@ impl HtmlEvent {
#[derive(Deserialize, Serialize, Debug, Clone, PartialEq)]
#[serde(untagged)]
#[non_exhaustive]
pub enum EventData {
Mouse(MouseData),
Clipboard(ClipboardData),
@@ -151,6 +153,7 @@ pub enum EventData {
Animation(AnimationData),
Transition(TransitionData),
Toggle(ToggleData),
Image(ImageData),
}
impl EventData {
@@ -172,6 +175,7 @@ impl EventData {
EventData::Animation(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::Image(data) => Rc::new(data) as Rc<dyn Any>,
}
}
}