From f17c7fdb905d0946d111d5f24c3df25b81f1c67e Mon Sep 17 00:00:00 2001 From: Greg Johnston Date: Wed, 14 Dec 2022 07:00:56 -0500 Subject: [PATCH] Remove duplicated `window_event_listener` --- leptos_dom/src/events.rs | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/leptos_dom/src/events.rs b/leptos_dom/src/events.rs index b205b7e9f..406849bc7 100644 --- a/leptos_dom/src/events.rs +++ b/leptos_dom/src/events.rs @@ -13,18 +13,6 @@ thread_local! { pub static GLOBAL_EVENTS: RefCell>> = RefCell::new(HashSet::new()); } -/// Adds an event listener to the `Window`. -#[cfg(all(target_arch = "wasm32", feature = "web"))] -pub fn window_event_listener( - event_name: &str, - cb: impl Fn(web_sys::Event) + 'static, -) { - let handler = Box::new(cb) as Box; - - let cb = Closure::wrap(handler).into_js_value(); - _ = window().add_event_listener_with_callback(event_name, cb.unchecked_ref()); -} - /// Adds an event listener to the target DOM element using implicit event delegation. #[cfg(all(target_arch = "wasm32", feature = "web"))] pub fn add_event_listener( @@ -111,7 +99,7 @@ pub(crate) fn add_delegated_event_listener(event_name: Cow<'static, str>) { } }; - window_event_listener(&event_name, handler); + crate::window_event_listener(&event_name, handler); // register that we've created handler events.insert(event_name);