LibWeb: Implement MediaQueryList.onchange

This commit is contained in:
Luke Wilde 2021-10-01 01:33:10 +01:00 committed by Linus Groh
parent 61e9e80232
commit 46686f7f94
Notes: sideshowbarker 2024-07-18 03:15:59 +09:00
3 changed files with 15 additions and 2 deletions

View File

@ -9,6 +9,7 @@
#include <LibWeb/DOM/Document.h>
#include <LibWeb/DOM/EventDispatcher.h>
#include <LibWeb/DOM/EventListener.h>
#include <LibWeb/HTML/EventHandler.h>
namespace Web::CSS {
@ -65,4 +66,14 @@ void MediaQueryList::remove_listener(RefPtr<DOM::EventListener> listener)
remove_event_listener(HTML::EventNames::change, listener);
}
void MediaQueryList::set_onchange(HTML::EventHandler event_handler)
{
set_event_handler_attribute(HTML::EventNames::change, event_handler);
}
HTML::EventHandler MediaQueryList::onchange()
{
return event_handler_attribute(HTML::EventNames::change);
}
}

View File

@ -44,6 +44,9 @@ public:
void add_listener(RefPtr<DOM::EventListener> listener);
void remove_listener(RefPtr<DOM::EventListener> listener);
void set_onchange(HTML::EventHandler);
HTML::EventHandler onchange();
private:
MediaQueryList(DOM::Document&, String);

View File

@ -2,8 +2,7 @@
interface MediaQueryList : EventTarget {
readonly attribute CSSOMString media;
readonly attribute boolean matches;
// TODO:
undefined addListener(EventListener? callback);
undefined removeListener(EventListener? callback);
// attribute EventHandler onchange;
attribute EventHandler onchange;
};