mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 08:47:34 +00:00
LibWeb: Add EventTarget::has_event_listener(FlyString type)
This returns true if the EventTarget has one or more registered listeners for a given even type.
This commit is contained in:
parent
51579810bd
commit
e0a08f2ab0
2 changed files with 11 additions and 0 deletions
|
@ -735,4 +735,13 @@ bool EventTarget::dispatch_event(Event& event)
|
|||
return EventDispatcher::dispatch(*this, event);
|
||||
}
|
||||
|
||||
bool EventTarget::has_event_listener(FlyString const& type) const
|
||||
{
|
||||
for (auto& listener : m_event_listener_list) {
|
||||
if (listener->type == type)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -54,6 +54,8 @@ public:
|
|||
WebIDL::CallbackType* event_handler_attribute(FlyString const& name);
|
||||
void set_event_handler_attribute(FlyString const& name, WebIDL::CallbackType*);
|
||||
|
||||
bool has_event_listener(FlyString const& type) const;
|
||||
|
||||
protected:
|
||||
explicit EventTarget(JS::Realm&);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue