From ebdb590469c67dfa07e77e72d2f26b2d9e0c2be9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rnar=20Hansen?= Date: Mon, 18 Jun 2018 16:48:37 +0200 Subject: [PATCH] fix(utils/element-matches.js): Use `node.matches*` in place of `prototype.matches*` (#956) Closes https://github.com/dequelabs/axe-core/issues/953 --- lib/core/utils/element-matches.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/core/utils/element-matches.js b/lib/core/utils/element-matches.js index 432109cf43..2e56877d67 100644 --- a/lib/core/utils/element-matches.js +++ b/lib/core/utils/element-matches.js @@ -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', @@ -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; } } @@ -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);