Skip to content

Commit

Permalink
fix(color-contrast-matches): do not pass empty string to getElementBy…
Browse files Browse the repository at this point in the history
…Id (#2739)
  • Loading branch information
straker committed Jan 8, 2021
1 parent 159e25b commit 0b0fec2
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions lib/rules/color-contrast-matches.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,17 @@ function colorContrastMatches(node, virtualNode) {
: virtualNode;

// explicit label of disabled control
const doc = getRootNode(labelNode);
const explicitControl = doc.getElementById(labelNode.htmlFor || '');
const explicitControlVirtual =
explicitControl && getNodeFromTree(explicitControl);
if (labelNode.htmlFor) {
const doc = getRootNode(labelNode);
const explicitControl = doc.getElementById(labelNode.htmlFor);
const explicitControlVirtual =
explicitControl && getNodeFromTree(explicitControl);

if (explicitControlVirtual && isDisabled(explicitControlVirtual)) {
return false;
if (explicitControlVirtual && isDisabled(explicitControlVirtual)) {
return false;
}
}

// implicit label of disabled control
const query =
'input:not([type="hidden"]):not([type="image"])' +
Expand Down

0 comments on commit 0b0fec2

Please sign in to comment.