1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 16:07:47 +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 {}; return {};
if (!callback_object->is_function()) if (!callback_object->is_function())
return interpreter.throw_exception<JS::TypeError>("Not a function"); return interpreter.throw_exception<JS::TypeError>("Not a function");
auto interval = interpreter.argument(1).to_i32(interpreter);
if (interpreter.exception()) i32 interval = 0;
return {}; 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); impl->set_interval(*static_cast<JS::Function*>(callback_object), interval);
return JS::js_undefined(); return JS::js_undefined();
} }