Skip to content

Commit

Permalink
fix(perf): Improve getSelector performance
Browse files Browse the repository at this point in the history
  • Loading branch information
dylanb committed Mar 1, 2018
1 parent 9c7b9f1 commit 737c81c
Show file tree
Hide file tree
Showing 11 changed files with 777 additions and 371 deletions.
1 change: 0 additions & 1 deletion lib/core/base/audit.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@ Audit.prototype.run = function (context, options, resolve, reject) {
}
});
q.then(function (results) {
axe._tree = undefined; // empty the tree
axe._selectCache = undefined; // remove the cache
resolve(results.filter(function (result) { return !!result; }));
}).catch(reject);
Expand Down
2 changes: 2 additions & 0 deletions lib/core/public/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ axe.run = function (context, options, callback) {
try {
let reporter = axe.getReporter(options.reporter);
let results = reporter(rawResults, options, respond);
axe._selectorData = undefined;
axe._tree = undefined;
if (results !== undefined) {
respond(results);
}
Expand Down
6 changes: 5 additions & 1 deletion lib/core/utils/collect-results-from-frames.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@

function err(message, node) {
'use strict';
return new Error(message + ': ' + axe.utils.getSelector(node));
var selector;
if (axe._tree) {
selector = axe.utils.getSelector(node);
}
return new Error(message + ': ' + (selector || node));
}

/**
Expand Down
Loading

0 comments on commit 737c81c

Please sign in to comment.