Enable event propagation (#3062)

This commit is contained in:
daxpedda 2023-08-28 19:18:10 +02:00 committed by GitHub
parent 7541220a41
commit 1dfca5a395
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 75 additions and 176 deletions

View file

@ -8,11 +8,11 @@ pub struct EventListenerHandle<T: ?Sized> {
}
impl<T: ?Sized> EventListenerHandle<T> {
pub fn new<U>(target: &U, event_type: &'static str, listener: Closure<T>) -> Self
pub fn new<U>(target: U, event_type: &'static str, listener: Closure<T>) -> Self
where
U: Clone + Into<EventTarget>,
U: Into<EventTarget>,
{
let target = target.clone().into();
let target = target.into();
target
.add_event_listener_with_callback(event_type, listener.as_ref().unchecked_ref())
.expect("Failed to add event listener");