mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-27 11:48:32 +00:00
LibWeb: Start working on DOM event support
This patch adds the EventTarget class and makes Node inherit from it. You can register event listeners on an EventTarget, and when you call dispatch_event() on it, the event listeners will get invoked. An event listener is basically a wrapper around a JS::Function*. This is pretty far from how DOM events should eventually work, but it's a place to start and we'll build more on top of this. :^)
This commit is contained in:
19
Libraries/LibWeb/DOM/EventTarget.cpp
Normal file
19
Libraries/LibWeb/DOM/EventTarget.cpp
Normal file
@@ -0,0 +1,19 @@
|
||||
#include <LibWeb/DOM/EventListener.h>
|
||||
#include <LibWeb/DOM/EventTarget.h>
|
||||
|
||||
namespace Web {
|
||||
|
||||
EventTarget::EventTarget()
|
||||
{
|
||||
}
|
||||
|
||||
EventTarget::~EventTarget()
|
||||
{
|
||||
}
|
||||
|
||||
void EventTarget::add_event_listener(String event_name, NonnullRefPtr<EventListener> listener)
|
||||
{
|
||||
m_listeners.append({ move(event_name), move(listener) });
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user