@@ -11,29 +11,7 @@ function isNumeric(value) {
1111 return ! Number . isNaN ( Number ( value ) ) ;
1212}
1313
14- function isValidAriaValue ( attrName , value ) {
15- const attrDef = aria . get ( attrName ) ;
16- if ( ! attrDef ) {
17- return true ;
18- }
19-
20- // Check whether 'undefined' is an explicit token in the attribute's value list
21- // (e.g. aria-orientation allows 'undefined' per aria-query) BEFORE applying the
22- // generic allowundefined shortcut. Otherwise valid tokens get rejected for
23- // attributes where allowundefined is false.
24- if (
25- value === 'undefined' &&
26- ( attrDef . type === 'token' || attrDef . type === 'tokenlist' ) &&
27- Array . isArray ( attrDef . values ) &&
28- attrDef . values . includes ( 'undefined' )
29- ) {
30- return true ;
31- }
32-
33- if ( value === 'undefined' ) {
34- return Boolean ( attrDef . allowundefined ) ;
35- }
36-
14+ function validateByType ( attrDef , value ) {
3715 switch ( attrDef . type ) {
3816 case 'boolean' : {
3917 return isBoolean ( value ) ;
@@ -73,6 +51,32 @@ function isValidAriaValue(attrName, value) {
7351 }
7452}
7553
54+ function isValidAriaValue ( attrName , value ) {
55+ const attrDef = aria . get ( attrName ) ;
56+ if ( ! attrDef ) {
57+ return true ;
58+ }
59+
60+ // Check whether 'undefined' is an explicit token in the attribute's value list
61+ // (e.g. aria-orientation allows 'undefined' per aria-query) BEFORE applying the
62+ // generic allowundefined shortcut. Otherwise valid tokens get rejected for
63+ // attributes where allowundefined is false.
64+ if (
65+ value === 'undefined' &&
66+ ( attrDef . type === 'token' || attrDef . type === 'tokenlist' ) &&
67+ Array . isArray ( attrDef . values ) &&
68+ attrDef . values . includes ( 'undefined' )
69+ ) {
70+ return true ;
71+ }
72+
73+ if ( value === 'undefined' ) {
74+ return Boolean ( attrDef . allowundefined ) ;
75+ }
76+
77+ return validateByType ( attrDef , value ) ;
78+ }
79+
7680function getExpectedTypeDescription ( attrName ) {
7781 const attrDef = aria . get ( attrName ) ;
7882 if ( ! attrDef ) {
0 commit comments