1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 21:17:44 +00:00

LibJS: Make Value::as_object() return Object&

Let's move towards using references over pointers in LibJS as well.
I had originally steered away from it because that's how I've seen
things done in other engines. But this is not the other engines. :^)
This commit is contained in:
Andreas Kling 2020-04-01 22:18:47 +02:00
parent b995a499d3
commit 1549c5c48b
8 changed files with 54 additions and 54 deletions

View file

@ -56,9 +56,9 @@ JS::Value EventTargetWrapper::add_event_listener(JS::Interpreter& interpreter)
return JS::js_undefined();
auto event_name = arguments[0].to_string();
ASSERT(arguments[1].is_object());
ASSERT(arguments[1].as_object()->is_function());
auto* function = static_cast<JS::Function*>(const_cast<Object*>(arguments[1].as_object()));
auto listener = adopt(*new EventListener(JS::make_handle(function)));
ASSERT(arguments[1].as_object().is_function());
auto& function = static_cast<JS::Function&>(const_cast<Object&>(arguments[1].as_object()));
auto listener = adopt(*new EventListener(JS::make_handle(&function)));
static_cast<EventTargetWrapper*>(this_object)->impl().add_event_listener(event_name, move(listener));
return JS::js_undefined();
}