From d2cf85dbe60f594a12cf9edb4ed53aa7040fcd66 Mon Sep 17 00:00:00 2001 From: Chinedu Francis Nwafili Date: Fri, 26 May 2023 10:11:24 -0400 Subject: [PATCH] Fix panic in Firefox (#193) This commit changes a `dyn_into()` into a `.unchecked_into()` since, for currently, unknown reasons `.dyn_into().unwrap()` was panicking in a real application Firefox (but not in our headless Firefox tests). The `web-sys` version was "0.3.61" --- crates/percy-dom/src/pdom/events.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/crates/percy-dom/src/pdom/events.rs b/crates/percy-dom/src/pdom/events.rs index c2c38ef3..8ca28fe4 100644 --- a/crates/percy-dom/src/pdom/events.rs +++ b/crates/percy-dom/src/pdom/events.rs @@ -18,8 +18,13 @@ impl PercyDom { let callback = move |event: web_sys::MouseEvent| { let target = event.target().unwrap(); + // `dyn_into().unwrap()` was crashing in Firefox (but not Chrome) when running a + // real-world application, even though our click event integration tests are passing + // in Firefox. + // This was observed in `web-sys 0.3.61` + let target_element: web_sys::Element = target.unchecked_into(); - bubble_event(target.dyn_into().unwrap(), MouseEvent::new(event), &events); + bubble_event(target_element, MouseEvent::new(event), &events); }; let callback = Box::new(callback) as Box; let callback = Closure::wrap(callback);