From df496cc8bcbe2e4bc0687fd3e8e678686d37b5cc Mon Sep 17 00:00:00 2001 From: Daniel Silverstone Date: Wed, 21 Aug 2019 21:46:52 +0100 Subject: Window: set{Timeout,Interval}() default delay 10ms Signed-off-by: Daniel Silverstone --- content/handlers/javascript/duktape/Window.bnd | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/content/handlers/javascript/duktape/Window.bnd b/content/handlers/javascript/duktape/Window.bnd index e7d45c80d..478f92b99 100644 --- a/content/handlers/javascript/duktape/Window.bnd +++ b/content/handlers/javascript/duktape/Window.bnd @@ -480,13 +480,11 @@ method Window::alert() method Window::setTimeout() %{ duk_idx_t argc = duk_get_top(ctx); - if (argc < 2) { - /* not enough arguments */ - return duk_error(ctx, DUK_RET_TYPE_ERROR, dukky_error_fmt_argument, 2, argc); + duk_int_t timeout = 10; + if (argc >= 2) { + timeout = duk_get_int(ctx, 1); } - - /* func, timeout, args... */ - duk_int_t timeout = duk_get_int(ctx, 1); + /* func, [timeout, args...] */ if (timeout < 10) { timeout = 10; } size_t handle = window_alloc_new_callback(ctx, priv, false, (int)timeout); @@ -497,13 +495,11 @@ method Window::setTimeout() method Window::setInterval() %{ duk_idx_t argc = duk_get_top(ctx); - if (argc < 2) { - /* not enough arguments */ - return duk_error(ctx, DUK_RET_TYPE_ERROR, dukky_error_fmt_argument, 2, argc); + duk_int_t timeout = 10; + if (argc >= 2) { + timeout = duk_get_int(ctx, 1); } - - /* func, timeout, args... */ - duk_int_t timeout = duk_get_int(ctx, 1); + /* func, [timeout, args...] */ if (timeout < 10) { timeout = 10; } size_t handle = window_alloc_new_callback(ctx, priv, true, (int)timeout); -- cgit v1.2.3