-
Notifications
You must be signed in to change notification settings - Fork 791
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(label,select-name): allow placeholder to pass label rule, add select-name rule #2448
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"id": "non-empty-placeholder", | ||
"evaluate": "attr-non-space-content-evaluate", | ||
"options": { | ||
"attribute": "placeholder" | ||
}, | ||
"metadata": { | ||
"impact": "serious", | ||
"messages": { | ||
"pass": "Element has a placeholder attribute", | ||
"fail": "Element has no placeholder attribute or the placeholder attribute is empty" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"id": "select-name", | ||
"selector": "select", | ||
"tags": [ | ||
"cat.forms", | ||
"wcag2a", | ||
"wcag412", | ||
"wcag131", | ||
"section508", | ||
"section508.22.n" | ||
], | ||
"metadata": { | ||
"description": "Ensures select element has an accessible name", | ||
"help": "Select element must have and accessible name" | ||
}, | ||
"all": [], | ||
"any": [ | ||
straker marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"aria-label", | ||
"aria-labelledby", | ||
"implicit-label", | ||
"explicit-label", | ||
"non-empty-title", | ||
"role-none", | ||
"role-presentation" | ||
], | ||
"none": ["help-same-as-label", "hidden-explicit-label"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
describe('non-empty-placeholder', function() { | ||
'use strict'; | ||
|
||
var fixture = document.getElementById('fixture'); | ||
var checkSetup = axe.testUtils.checkSetup; | ||
var checkEvaluate = axe.testUtils.getCheckEvaluate('non-empty-placeholder'); | ||
|
||
afterEach(function() { | ||
fixture.innerHTML = ''; | ||
}); | ||
|
||
it('should return true if a placeholder is present', function() { | ||
var params = checkSetup('<input id="target" placeholder="woohoo" />'); | ||
|
||
assert.isTrue(checkEvaluate.apply(null, params)); | ||
}); | ||
|
||
it('should return false if a placeholder is not present', function() { | ||
var params = checkSetup('<input id="target" />'); | ||
|
||
assert.isFalse(checkEvaluate.apply(null, params)); | ||
}); | ||
|
||
it('should return false if a placeholder is present, but empty', function() { | ||
var params = checkSetup('<input id="target" placeholder=" " />'); | ||
|
||
assert.isFalse(checkEvaluate.apply(null, params)); | ||
}); | ||
|
||
it('should collapse whitespace', function() { | ||
var params = checkSetup( | ||
'<input id="target" placeholder=" \t \n \r \t \t\r\n " />' | ||
); | ||
|
||
assert.isFalse(checkEvaluate.apply(null, params)); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<form action="#"> | ||
<select id="fail1"></select> | ||
<select aria-label="label" id="pass1"></select> | ||
<select aria-labelledby="label" id="pass2"></select> | ||
<div id="label">Label</div> | ||
<label> | ||
Label | ||
<select id="pass3"></select> | ||
</label> | ||
|
||
<label><select id="fail2"></select></label> | ||
<label for="fail3"> | ||
<select id="fail3"> | ||
<option>Thing</option> | ||
</select> | ||
</label> | ||
<label for="pass4">Label</label> | ||
<select id="pass4"></select> | ||
|
||
<select id="pass5" title="Label"></select> | ||
|
||
<select id="pass6" role="presentation"></select> | ||
<select id="pass7" role="none"></select> | ||
|
||
<div> | ||
<label> | ||
<select id="fail4"> | ||
<option selected="selected">Chosen</option> | ||
<option>Not Selected</option> | ||
</select> | ||
</label> | ||
</div> | ||
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"description": "select-name test", | ||
"rule": "select-name", | ||
"violations": [["#fail1"], ["#fail2"], ["#fail3"], ["#fail4"]], | ||
"passes": [ | ||
["#pass1"], | ||
["#pass2"], | ||
["#pass3"], | ||
["#pass4"], | ||
["#pass5"], | ||
["#pass6"], | ||
["#pass7"] | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets distinguish between these two. I realise this is also true for non-empty-title, I'll open a tech debt ticket for that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doing this would make the generic check
attr-non-space-content
change, which in turn affects the 3 other checks that rely on it:none-empty-alt
,none-empty-value
,non-empty-title
(the tests and messages would need to be updated in each of those to handlethis.data
being called in the check).As such, this change would be outside the scope of the PR and I vote we do this in a separate PR (the ticket you created).