From 089da915cc7b7d0ec8db73ecfd623e390fc0465d Mon Sep 17 00:00:00 2001 From: Alexandre Dieulot Date: Tue, 6 Aug 2019 16:21:24 +0200 Subject: [PATCH] Check if `requestIdleCallback` exists in `window` (#112) Fixes the following error when not transpiled: > Uncaught ReferenceError: Cannot access 'requestIdleCallback' before initialization > at request-idle-callback.mjs:18 --- src/request-idle-callback.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/request-idle-callback.mjs b/src/request-idle-callback.mjs index 9ce87d35..2509e642 100644 --- a/src/request-idle-callback.mjs +++ b/src/request-idle-callback.mjs @@ -15,7 +15,7 @@ **/ // RIC and shim for browsers setTimeout() without it -const requestIdleCallback = requestIdleCallback || +const requestIdleCallback = window.requestIdleCallback || function (cb) { const start = Date.now(); return setTimeout(function () {