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

@ -138,18 +138,6 @@ impl Event {
self.cancelable.set(cancelable);
}
// Determine if there are any listeners for a given target and type.
// See https://github.com/whatwg/dom/issues/453
pub fn has_listeners_for(&self, target: &EventTarget, type_: &Atom) -> bool {
// TODO: take 'removed' into account? Not implemented in Servo yet.
// https://dom.spec.whatwg.org/#event-listener-removed
let mut event_path = self.construct_event_path(&target);
event_path.push(DomRoot::from_ref(target));
event_path
.iter()
.any(|target| target.has_listeners_for(type_))
}
// https://dom.spec.whatwg.org/#event-path
// TODO: shadow roots put special flags in the path,
// and it will stop just being a list of bare EventTargets