Skip to content

Commit

Permalink
fix(axe.run): allow returning a Promise in jsdom (#943)
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
stephenmathieson authored and WilcoFiers committed Jun 7, 2018
1 parent 7ec753a commit 3858a1f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/core/public/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -143,4 +143,4 @@ axe.run = function (context, options, callback) {
});

return p;
};
};

0 comments on commit 3858a1f

Please sign in to comment.