From 7a47a3665290f18a51a13fb183e3c388bff83691 Mon Sep 17 00:00:00 2001 From: Luke Childs Date: Mon, 16 Jan 2017 19:07:46 +0700 Subject: [PATCH] Allow doc to be passed in as the lone first param --- src/index.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/index.js b/src/index.js index 31e0e7d..9c77faf 100644 --- a/src/index.js +++ b/src/index.js @@ -3,6 +3,12 @@ const loadedStates = ['interactive', 'complete']; // Return Promise module.exports = (cb, doc) => new Promise(resolve => { + // Allow doc to be passed in as the lone first param + if (cb && typeof cb !== 'function') { + doc = cb; + cb = null; + } + // Use global document if we don't have one doc = doc || document;