Skip to content

Commit

Permalink
fix: ensure document is fetched from correct node
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcy Sutton committed Jul 13, 2017
1 parent f0fe551 commit b28597c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/rules/color-contrast-matches.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
/* global document */

var nodeName = node.nodeName.toUpperCase(),
nodeType = node.type,
doc = axe.commons.dom.getRootNode(node);
nodeType = node.type;

if (node.getAttribute('aria-disabled') === 'true' || axe.commons.dom.findUp(node, '[aria-disabled="true"]')) {
return false;
Expand Down Expand Up @@ -40,6 +39,7 @@ if (nodeName === 'LABEL' || nodeParentLabel) {
relevantNode = nodeParentLabel;
}
// explicit label of disabled input
let doc = axe.commons.dom.getRootNode(relevantNode);
var candidate = relevantNode.htmlFor && doc.getElementById(relevantNode.htmlFor);
if (candidate && candidate.disabled) {
return false;
Expand All @@ -55,6 +55,7 @@ if (nodeName === 'LABEL' || nodeParentLabel) {

// label of disabled control associated w/ aria-labelledby
if (node.id) {
let doc = axe.commons.dom.getRootNode(node);
var candidate = doc.querySelector('[aria-labelledby~=' + axe.commons.utils.escapeSelector(node.id) + ']');
if (candidate && candidate.disabled) {
return false;
Expand Down

0 comments on commit b28597c

Please sign in to comment.