mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 14:28:12 +00:00
LibWeb: Mark event listeners generated by event handler attributes
We have to mark the EventListener objects so that we can tell them apart from listeners added via the addEventListener() API. This makes element.onfoo getters actually return the handler function.
This commit is contained in:
parent
5f4a723e51
commit
5ac82efbe1
1 changed files with 2 additions and 2 deletions
|
@ -124,7 +124,7 @@ void EventTarget::set_event_handler_attribute(FlyString const& name, HTML::Event
|
|||
|
||||
RefPtr<DOM::EventListener> listener;
|
||||
if (!value.callback.is_null()) {
|
||||
listener = adopt_ref(*new DOM::EventListener(move(value.callback)));
|
||||
listener = adopt_ref(*new DOM::EventListener(move(value.callback), true));
|
||||
} else {
|
||||
StringBuilder builder;
|
||||
builder.appendff("function {}(event) {{\n{}\n}}", name, value.string);
|
||||
|
@ -136,7 +136,7 @@ void EventTarget::set_event_handler_attribute(FlyString const& name, HTML::Event
|
|||
}
|
||||
auto* function = JS::ECMAScriptFunctionObject::create(target->script_execution_context()->realm().global_object(), name, program->body(), program->parameters(), program->function_length(), nullptr, JS::FunctionKind::Regular, false, false);
|
||||
VERIFY(function);
|
||||
listener = adopt_ref(*new DOM::EventListener(JS::make_handle(static_cast<JS::FunctionObject*>(function))));
|
||||
listener = adopt_ref(*new DOM::EventListener(JS::make_handle(static_cast<JS::FunctionObject*>(function)), true));
|
||||
}
|
||||
if (listener) {
|
||||
for (auto& registered_listener : target->listeners()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue