mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
implement "has event listener", plug into (before)unload
This commit is contained in:
parent
427eaed535
commit
29d1cf6270
9 changed files with 66 additions and 56 deletions
|
@ -277,6 +277,12 @@ impl EventListeners {
|
|||
}
|
||||
}).collect()
|
||||
}
|
||||
|
||||
fn has_listeners(&self) -> bool {
|
||||
// TODO: add, and take into account, a 'removed' field?
|
||||
// https://dom.spec.whatwg.org/#event-listener-removed
|
||||
self.0.len() > 0
|
||||
}
|
||||
}
|
||||
|
||||
#[dom_struct]
|
||||
|
@ -303,6 +309,15 @@ impl EventTarget {
|
|||
Ok(EventTarget::new(global))
|
||||
}
|
||||
|
||||
pub fn has_listeners_for(&self,
|
||||
type_: &Atom)
|
||||
-> bool {
|
||||
match self.handlers.borrow().get(type_) {
|
||||
Some(listeners) => listeners.has_listeners(),
|
||||
None => false
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_listeners_for(&self,
|
||||
type_: &Atom,
|
||||
specific_phase: Option<ListenerPhase>)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue