Skip to content

Commit

Permalink
fix: Allow <track> to have no kind attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
WilcoFiers committed Jul 14, 2017
1 parent 0f21574 commit f996d0f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/checks/media/caption.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ var tracks = axe.utils.querySelectorAll(virtualNode, 'track');
if (tracks.length) {
// return false if any track has kind === 'caption'
return !tracks.some(({ actualNode }) => (
actualNode.getAttribute('kind').toLowerCase() === 'captions'
(actualNode.getAttribute('kind') || '').toLowerCase() === 'captions'
));
}
// Undefined if there are no tracks - media may be decorative
Expand Down
2 changes: 1 addition & 1 deletion lib/checks/media/description.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ var tracks = axe.utils.querySelectorAll(virtualNode, 'track');
if (tracks.length) {
// return false if any track has kind === 'description'
var out = !tracks.some(({ actualNode }) => (
actualNode.getAttribute('kind').toLowerCase() === 'descriptions'
(actualNode.getAttribute('kind') || '').toLowerCase() === 'descriptions'
));
axe.log(tracks.map(t => t.actualNode.getAttribute('kind')), out);
return out;
Expand Down
5 changes: 5 additions & 0 deletions test/checks/media/caption.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ describe('caption', function () {
assert.isTrue(checks.caption.evaluate.apply(null, checkArgs));
});

it('should fail if there is no kind attribute', function () {
var checkArgs = checkSetup('<video><track></video>', 'video');
assert.isTrue(checks.description.evaluate.apply(null, checkArgs));
});

it('should pass if there is a kind=captions attribute', function () {
var checkArgs = checkSetup('<audio><track kind=captions></audio>', 'audio');
assert.isFalse(checks.caption.evaluate.apply(null, checkArgs));
Expand Down
5 changes: 5 additions & 0 deletions test/checks/media/description.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ describe('description', function () {
assert.isTrue(checks.description.evaluate.apply(null, checkArgs));
});

it('should fail if there is no kind attribute', function () {
var checkArgs = checkSetup('<video><track></video>', 'video');
assert.isTrue(checks.description.evaluate.apply(null, checkArgs));
});

it('should pass if there is a kind=descriptions attribute', function () {
var checkArgs = checkSetup('<video><track kind=descriptions></video>', 'video');
assert.isFalse(checks.description.evaluate.apply(null, checkArgs));
Expand Down

0 comments on commit f996d0f

Please sign in to comment.