From 3858a1f4d77c2e236f5573ade4d69dcc1fd7be84 Mon Sep 17 00:00:00 2001 From: Stephen Mathieson Date: Thu, 7 Jun 2018 04:48:34 -0400 Subject: [PATCH] fix(axe.run): allow returning a Promise in jsdom (#943) This patch enables `axe.run()` to return a Promise when `window.Promise` is not defined, but there is a Promise implementation in the global scope. This, while very edge-casey, enables me to run axe in a node process by only importing [`jsdom-global/register`](https://github.com/rstacruz/jsdom-global). --- lib/core/public/run.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/core/public/run.js b/lib/core/public/run.js index 1389734b91..3575f9a27d 100644 --- a/lib/core/public/run.js +++ b/lib/core/public/run.js @@ -105,7 +105,7 @@ axe.run = function (context, options, callback) { let reject = noop; let resolve = noop; - if (window.Promise && callback === noop) { + if (typeof Promise === 'function' && callback === noop) { p = new Promise(function (_resolve, _reject) { reject = _reject; resolve = _resolve; @@ -143,4 +143,4 @@ axe.run = function (context, options, callback) { }); return p; -}; \ No newline at end of file +};