From b53a34b7d1b4b71336333f78e2c2e72192d993b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Debongnie?= Date: Sat, 8 Jun 2019 16:20:44 +0200 Subject: [PATCH] [FIX] utils: whenReady should work for all document states Document readyState can be either 'loading', 'interactive' or 'complete'. We can access the DOM whenever we are no longer in 'loading' state. --- src/utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils.ts b/src/utils.ts index fdb9d01a..0ac0da7f 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -11,7 +11,7 @@ */ export function whenReady(fn) { - if (document.readyState === "complete") { + if (document.readyState !== "loading") { fn(); } else { document.addEventListener("DOMContentLoaded", fn, false);