File tree Expand file tree Collapse file tree 3 files changed +19
-2
lines changed Expand file tree Collapse file tree 3 files changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -55,7 +55,7 @@ aria.validateAttr = function (att) {
55
55
* @return {Boolean }
56
56
*/
57
57
aria . validateAttrValue = function ( node , attr ) {
58
- /*eslint complexity: ["error",15 ]*/
58
+ /*eslint complexity: ["error",17 ]*/
59
59
'use strict' ;
60
60
var matches , list ,
61
61
value = node . getAttribute ( attr ) ,
@@ -84,6 +84,10 @@ aria.validateAttrValue = function (node, attr) {
84
84
return ! ! ( value && doc . getElementById ( value ) ) ;
85
85
86
86
case 'idrefs' :
87
+ // exempt attributes that allow empty strings
88
+ if ( ( attrInfo . values && attrInfo . values . indexOf ( '' ) !== - 1 ) && value . trim ( ) . length === 0 ) {
89
+ return true ;
90
+ }
87
91
list = axe . utils . tokenList ( value ) ;
88
92
// Check if any value isn't in the list of values
89
93
return list . reduce ( function ( result , token ) {
Original file line number Diff line number Diff line change @@ -87,7 +87,8 @@ lookupTable.attributes = {
87
87
type : 'string'
88
88
} ,
89
89
'aria-labelledby' : {
90
- type : 'idrefs'
90
+ type : 'idrefs' ,
91
+ values : [ '' ]
91
92
} ,
92
93
'aria-level' : {
93
94
type : 'int'
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ describe('aria-valid-attr-value', function () {
3
3
4
4
var fixture = document . getElementById ( 'fixture' ) ;
5
5
var checkContext = axe . testUtils . MockCheckContext ( ) ;
6
+ var fixtureSetup = axe . testUtils . fixtureSetup ;
6
7
7
8
afterEach ( function ( ) {
8
9
fixture . innerHTML = '' ;
@@ -89,6 +90,17 @@ describe('aria-valid-attr-value', function () {
89
90
axe . commons . aria . validateAttrValue = orig ;
90
91
} ) ;
91
92
93
+ it ( 'should allow empty strings rather than idrefs for specific attributes' , function ( ) {
94
+ fixtureSetup (
95
+ '<button aria-labelledby="">Button</button>' +
96
+ '<div aria-owns=""></div>'
97
+ ) ;
98
+ var passing = fixture . querySelector ( 'button' ) ;
99
+ var failing = fixture . querySelector ( 'div' ) ;
100
+ assert . isTrue ( checks [ 'aria-valid-attr-value' ] . evaluate . call ( checkContext , passing ) ) ;
101
+ assert . isFalse ( checks [ 'aria-valid-attr-value' ] . evaluate . call ( checkContext , failing ) ) ;
102
+ } ) ;
103
+
92
104
describe ( 'options' , function ( ) {
93
105
it ( 'should exclude supplied attributes' , function ( ) {
94
106
fixture . innerHTML = '<div id="target" aria-live="nope" aria-describedby="no exist k thx"></div>' ;
You can’t perform that action at this time.
0 commit comments