Skip to content

Commit 6f7dc93

Browse files
fracmakbeefancohen
authored andcommitted
Fixing aria-invalid=true and aria-invalid=false validation (#126)
1 parent 6a13d18 commit 6f7dc93

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

__tests__/src/rules/aria-proptypes-test.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,12 @@ ruleTester.run('aria-proptypes', rule, {
123123
{ code: '<div aria-sort={`other`} />', parserOptions },
124124
{ code: '<div aria-sort={foo} />', parserOptions },
125125
{ code: '<div aria-sort={foo.bar} />', parserOptions },
126+
{ code: '<div aria-invalid={true} />', parserOptions },
127+
{ code: '<div aria-invalid="true" />', parserOptions },
128+
{ code: '<div aria-invalid={false} />', parserOptions },
129+
{ code: '<div aria-invalid="false" />', parserOptions },
130+
{ code: '<div aria-invalid="grammar" />', parserOptions },
131+
{ code: '<div aria-invalid="spelling" />', parserOptions },
126132

127133
// TOKENLIST
128134
{ code: '<div aria-relevant="additions" />', parserOptions },

src/rules/aria-proptypes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const validityCheck = (value, expectedType, permittedValues) => {
4242
// Booleans resolve to 0/1 values so hard check that it's not first.
4343
return typeof value !== 'boolean' && isNaN(Number(value)) === false;
4444
case 'token':
45-
return typeof value === 'string' && permittedValues.indexOf(value.toLowerCase()) > -1;
45+
return permittedValues.indexOf(typeof value === 'string' ? value.toLowerCase() : value) > -1;
4646
case 'tokenlist':
4747
return typeof value === 'string' &&
4848
value.split(' ').every(token => permittedValues.indexOf(token.toLowerCase()) > -1);

src/util/attributes/ARIA.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
},
4848
"ARIA-INVALID": {
4949
"type": "token",
50-
"values": [ "grammar", "false", "spelling", "true" ]
50+
"values": [ "grammar", false, "spelling", true ]
5151
},
5252
"ARIA-LABEL": {
5353
"type": "string"

0 commit comments

Comments
 (0)