LibWeb: Add function to EventTarget that says if it has any listeners

Required by XHR to determine if it should use CORS-preflight if its
upload object has any event listeners.
This commit is contained in:
Luke Wilde 2023-02-28 18:39:11 +00:00 committed by Linus Groh
parent acd5382924
commit 80fad65e5b
Notes: sideshowbarker 2024-07-17 10:54:57 +09:00
2 changed files with 6 additions and 0 deletions

View File

@ -744,4 +744,9 @@ bool EventTarget::has_event_listener(DeprecatedFlyString const& type) const
return false;
}
bool EventTarget::has_event_listeners() const
{
return !m_event_listener_list.is_empty();
}
}

View File

@ -55,6 +55,7 @@ public:
void set_event_handler_attribute(DeprecatedFlyString const& name, WebIDL::CallbackType*);
bool has_event_listener(DeprecatedFlyString const& type) const;
bool has_event_listeners() const;
protected:
explicit EventTarget(JS::Realm&);