mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 06:57:44 +00:00
LibWeb: Let various functions throw if not enough arguments
...instead of handing out null / undefined / empty values.
This commit is contained in:
parent
2d503b20da
commit
e3e9749d88
3 changed files with 9 additions and 8 deletions
|
@ -27,6 +27,7 @@
|
|||
#include <AK/FlyString.h>
|
||||
#include <AK/Function.h>
|
||||
#include <LibJS/Interpreter.h>
|
||||
#include <LibJS/Runtime/Error.h>
|
||||
#include <LibJS/Runtime/Function.h>
|
||||
#include <LibJS/Runtime/GlobalObject.h>
|
||||
#include <LibWeb/Bindings/EventListenerWrapper.h>
|
||||
|
@ -54,7 +55,7 @@ JS::Value EventTargetWrapper::add_event_listener(JS::Interpreter& interpreter)
|
|||
if (!this_object)
|
||||
return {};
|
||||
if (interpreter.argument_count() < 2)
|
||||
return JS::js_undefined();
|
||||
return interpreter.throw_exception<JS::TypeError>("addEventListener() needs two arguments");
|
||||
auto event_name = interpreter.argument(0).to_string(interpreter);
|
||||
if (interpreter.exception())
|
||||
return {};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue