mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-28 11:49: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
Notes:
sideshowbarker
2024-07-19 06:17:19 +09:00
Author: https://github.com/linusg
Commit: e3e9749d88
Pull-request: https://github.com/SerenityOS/serenity/pull/2318
3 changed files with 9 additions and 8 deletions
|
@ -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 {};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue