From b05842c59bf6f683529fae1cda84f26e87623178 Mon Sep 17 00:00:00 2001 From: Johan van Eck Date: Wed, 12 Jun 2019 21:02:03 +0200 Subject: [PATCH 1/4] Make sure requestAnimationFrame has the correct context when triggered --- src/runtime/internal/utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/runtime/internal/utils.ts b/src/runtime/internal/utils.ts index 152c0e79b02b..c961768eb022 100644 --- a/src/runtime/internal/utils.ts +++ b/src/runtime/internal/utils.ts @@ -96,7 +96,7 @@ export let now: () => number = is_client ? () => window.performance.now() : () => Date.now(); -export let raf = is_client ? requestAnimationFrame : noop; +export let raf = is_client ? requestAnimationFrame.bind(window) : noop; // used internally for testing export function set_now(fn) { From 7a89c7818534e7ad277549abbe322d628dd2498b Mon Sep 17 00:00:00 2001 From: Johan van Eck Date: Wed, 12 Jun 2019 21:26:44 +0200 Subject: [PATCH 2/4] Fix specs --- src/runtime/internal/utils.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/runtime/internal/utils.ts b/src/runtime/internal/utils.ts index c961768eb022..e63daf64a4dc 100644 --- a/src/runtime/internal/utils.ts +++ b/src/runtime/internal/utils.ts @@ -87,7 +87,7 @@ export function once(fn) { if (ran) return; ran = true; fn.call(this, ...args); - } + }; } const is_client = typeof window !== 'undefined'; @@ -96,7 +96,9 @@ export let now: () => number = is_client ? () => window.performance.now() : () => Date.now(); -export let raf = is_client ? requestAnimationFrame.bind(window) : noop; +export let raf = (callback) => is_client && window.requestAnimationFrame + ? window.requestAnimationFrame.apply(window, callback) + : undefined; // used internally for testing export function set_now(fn) { From 6c01c272f0b081a9ac3d845dbed888d8942886dd Mon Sep 17 00:00:00 2001 From: Johan van Eck Date: Thu, 13 Jun 2019 20:10:01 +0200 Subject: [PATCH 3/4] Move from apply to call --- src/runtime/internal/utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/runtime/internal/utils.ts b/src/runtime/internal/utils.ts index e63daf64a4dc..65e64a7c1218 100644 --- a/src/runtime/internal/utils.ts +++ b/src/runtime/internal/utils.ts @@ -97,7 +97,7 @@ export let now: () => number = is_client : () => Date.now(); export let raf = (callback) => is_client && window.requestAnimationFrame - ? window.requestAnimationFrame.apply(window, callback) + ? window.requestAnimationFrame.call(window, callback) : undefined; // used internally for testing From 049973eb2dbed6986ca432d1ea54d86d131735a3 Mon Sep 17 00:00:00 2001 From: Conduitry Date: Sun, 16 Jun 2019 05:06:25 -0400 Subject: [PATCH 4/4] simplify --- src/runtime/internal/utils.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/runtime/internal/utils.ts b/src/runtime/internal/utils.ts index 65e64a7c1218..097a7df74bfd 100644 --- a/src/runtime/internal/utils.ts +++ b/src/runtime/internal/utils.ts @@ -96,9 +96,7 @@ export let now: () => number = is_client ? () => window.performance.now() : () => Date.now(); -export let raf = (callback) => is_client && window.requestAnimationFrame - ? window.requestAnimationFrame.call(window, callback) - : undefined; +export let raf = cb => requestAnimationFrame(cb); // used internally for testing export function set_now(fn) {