Skip to content

Commit

Permalink
Merged in KSD-464 (pull request dequelabs#130)
Browse files Browse the repository at this point in the history
KSD-464 do not report on disabled inputs / buttons
  • Loading branch information
Mike Kozlowski committed Feb 16, 2015
2 parents 3864b3e + 7db6d70 commit 783279f
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lib/checks/color/color-contrast-matches.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
var nodeName = node.nodeName,
nodeType = node.type;

if (nodeName === 'INPUT') {
return ['hidden', 'range', 'color', 'checkbox', 'radio'].indexOf(nodeType) === -1;
return ['hidden', 'range', 'color', 'checkbox', 'radio'].indexOf(nodeType) === -1 && !node.disabled;
}

if (nodeName === 'SELECT') {
return !!node.options.length;
return !!node.options.length && !node.disabled;
}

if (nodeName === 'TEXTAREA') {
return true;
return !node.disabled;
}

if (nodeName === 'OPTION') {
return false;
}

if (nodeName === 'BUTTON' && node.disabled) {
return false;
}

if (kslib.text.visible(node, false, true) === '') {
return false;
}
Expand Down
31 changes: 31 additions & 0 deletions test/checks/color/color-contrast.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,37 @@ describe('color-contrast', function () {
var target = fixture.querySelector('option');
assert.isFalse(checks['color-contrast'].matches(target));
});

it('should not match inputs that are disabled', function () {
fixture.innerHTML = '<input type="text" disabled>';
var target = fixture.querySelector('input');
assert.isFalse(checks['color-contrast'].matches(target));

});

it('should not match <textarea disabled>', function () {
fixture.innerHTML = '<textarea disabled></textarea>';
var target = fixture.querySelector('textarea');
assert.isFalse(checks['color-contrast'].matches(target));
});

it('should not match <select> with options', function () {
fixture.innerHTML = '<select disabled><option>Hello</option></select>';
var target = fixture.querySelector('select');
assert.isFalse(checks['color-contrast'].matches(target));
});

it('should match <button>', function () {
fixture.innerHTML = '<button>hi</button>';
var target = fixture.querySelector('button');
assert.isTrue(checks['color-contrast'].matches(target));
});

it('should not match <button disabled>', function () {
fixture.innerHTML = '<button disabled>hi</button>';
var target = fixture.querySelector('button');
assert.isFalse(checks['color-contrast'].matches(target));
});
});

});

0 comments on commit 783279f

Please sign in to comment.