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

LibWeb: Allow setInterval() with no interval

This commit is contained in:
Linus Groh 2020-05-21 01:10:44 +01:00 committed by Andreas Kling
parent e3e9749d88
commit c769784406

View file

@ -135,9 +135,14 @@ JS::Value WindowObject::set_interval(JS::Interpreter& interpreter)
return {};
if (!callback_object->is_function())
return interpreter.throw_exception<JS::TypeError>("Not a function");
auto interval = interpreter.argument(1).to_i32(interpreter);
if (interpreter.exception())
return {};
i32 interval = 0;
if (interpreter.argument_count() >= 2) {
interval = interpreter.argument(1).to_i32(interpreter);
if (interpreter.exception())
return {};
}
impl->set_interval(*static_cast<JS::Function*>(callback_object), interval);
return JS::js_undefined();
}