1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 22:38:13 +00:00

LibWeb: Let various functions throw if not enough arguments

...instead of handing out null / undefined / empty values.
This commit is contained in:
Linus Groh 2020-05-21 00:55:01 +01:00 committed by Andreas Kling
parent 2d503b20da
commit e3e9749d88
3 changed files with 9 additions and 8 deletions

View file

@ -76,7 +76,7 @@ JS::Value DocumentWrapper::get_element_by_id(JS::Interpreter& interpreter)
if (!document)
return {};
if (!interpreter.argument_count())
return JS::js_null();
return interpreter.throw_exception<JS::TypeError>("getElementById() needs one argument");
auto id = interpreter.argument(0).to_string(interpreter);
if (interpreter.exception())
return {};
@ -92,7 +92,7 @@ JS::Value DocumentWrapper::query_selector_all(JS::Interpreter& interpreter)
if (!document)
return {};
if (!interpreter.argument_count())
return JS::js_null();
return interpreter.throw_exception<JS::TypeError>("querySelectorAll() needs one argument");
auto selector = interpreter.argument(0).to_string(interpreter);
if (interpreter.exception())
return {};