mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 03:55:24 +00:00
LibWeb: Allow window.setTimeout() with no interval
If no interval is specified, it will be treated as 0 and the callback function will be called on the next event loop iteration.
This commit is contained in:
parent
003741db1c
commit
6e5c9970bf
Notes:
sideshowbarker
2024-07-19 07:52:43 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/6e5c9970bf0
1 changed files with 7 additions and 2 deletions
|
@ -104,14 +104,19 @@ JS::Value WindowObject::set_timeout(JS::Interpreter& interpreter)
|
|||
if (!impl)
|
||||
return {};
|
||||
auto& arguments = interpreter.call_frame().arguments;
|
||||
if (arguments.size() < 2)
|
||||
if (arguments.size() < 1)
|
||||
return {};
|
||||
auto* callback_object = arguments[0].to_object(interpreter.heap());
|
||||
if (!callback_object)
|
||||
return {};
|
||||
if (!callback_object->is_function())
|
||||
return interpreter.throw_exception<JS::Error>("TypeError", "Not a function");
|
||||
impl->set_timeout(*static_cast<JS::Function*>(callback_object), arguments[1].to_i32());
|
||||
|
||||
i32 interval = 0;
|
||||
if (interpreter.argument_count() >= 2)
|
||||
interval = arguments[1].to_i32();
|
||||
|
||||
impl->set_timeout(*static_cast<JS::Function*>(callback_object), interval);
|
||||
return {};
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue