Skip to content

Commit

Permalink
fix(utils/element-matches.js): Use node.matches* in place of `proto…
Browse files Browse the repository at this point in the history
…type.matches*` (#956)

Closes #953
  • Loading branch information
zkf authored and WilcoFiers committed Jun 18, 2018
1 parent 3858a1f commit ebdb590
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions lib/core/utils/element-matches.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ axe.utils.matchesSelector = (function () {

var method;

function getMethod(win) {
function getMethod(node) {

var index, candidate,
elProto = win.Element.prototype,
candidates = [
'matches',
'matchesSelector',
Expand All @@ -24,7 +23,7 @@ axe.utils.matchesSelector = (function () {

for (index = 0; index < length; index++) {
candidate = candidates[index];
if (elProto[candidate]) {
if (node[candidate]) {
return candidate;
}
}
Expand All @@ -34,7 +33,7 @@ axe.utils.matchesSelector = (function () {
return function (node, selector) {

if (!method || !node[method]) {
method = getMethod(node.ownerDocument.defaultView);
method = getMethod(node);
}

return node[method](selector);
Expand Down

0 comments on commit ebdb590

Please sign in to comment.