make the concept of has_listeners_for follow other implementations (#21044)

Co-authored-by: Gregory Terzian <gterzian@users.noreply.github.com>
This commit is contained in:
Gregory Terzian 2023-07-19 23:27:32 +08:00 committed by GitHub
parent 4f4c2a5922
commit cf9ec700de
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 14 deletions

View file

@ -367,6 +367,8 @@ impl EventTarget {
Ok(EventTarget::new(global, proto))
}
/// Determine if there are any listeners for a given event type.
/// See <https://github.com/whatwg/dom/issues/453>.
pub fn has_listeners_for(&self, type_: &Atom) -> bool {
match self.handlers.borrow().get(type_) {
Some(listeners) => listeners.has_listeners(),