Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(rule): no-autoplay-audio #1946

Merged
merged 24 commits into from
Jan 20, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
use excludeHidden over isHidden fn
  • Loading branch information
jeeyyy committed Jan 16, 2020
commit 1ea98ba91b03ede3f5a88e595d35a15c35001a21
8 changes: 0 additions & 8 deletions lib/core/utils/is-hidden.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,6 @@ axe.utils.isHidden = function isHidden(el, recursed) {
return false;
}

/**
* Handle media elements that can be hidden by the absence of an attribute
* Eg: `audio` without `controls` attribute is hidden by default,
*/
if (el.nodeName.toUpperCase() === `AUDIO` && !el.hasAttribute('controls')) {
return false;
}

// 11 === Node.DOCUMENT_FRAGMENT_NODE
if (el.nodeType === 11) {
el = el.host; // grab the host Node
Expand Down
1 change: 1 addition & 0 deletions lib/rules/no-autoplay-audio.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"id": "no-autoplay-audio",
"excludeHidden": false,
"selector": "audio[autoplay], video[autoplay]",
"matches": "no-autoplay-audio-matches.js",
"tags": ["wcag2a", "wcag142", "experimental"],
Expand Down
21 changes: 0 additions & 21 deletions test/core/utils/is-hidden.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,27 +40,6 @@ describe('axe.utils.isHidden', function() {
assert.isFalse(axe.utils.isHidden(document));
});

it('should return false on a `audio` element without `controls` attribute', function() {
fixture.innerHTML =
'<audio id="target" src="/test/assets/moon-speech.mp3"></audio>';
var el = document.getElementById('target');
assert.isFalse(axe.utils.isHidden(el));
});

it('should return false on a `audio` element with `controls` attribute', function() {
fixture.innerHTML =
'<audio id="target" src="/test/assets/moon-speech.mp3" controls></audio>';
var el = document.getElementById('target');
assert.isFalse(axe.utils.isHidden(el));
});

it('should return true on a `audio` element with `controls` attribute but `display:none`', function() {
fixture.innerHTML =
'<audio id="target" src="/test/assets/moon-speech.mp3" style="display: none" controls></audio>';
var el = document.getElementById('target');
assert.isTrue(axe.utils.isHidden(el));
});

it('should return true if `aria-hidden` is set', function() {
fixture.innerHTML =
'<div id="target" aria-hidden="true">Hidden from screen readers</div>';
Expand Down