@@ -23,6 +23,7 @@ import { string_literal } from '../utils/stringify';
23
23
import { Literal } from 'estree' ;
24
24
import compiler_warnings from '../compiler_warnings' ;
25
25
import compiler_errors from '../compiler_errors' ;
26
+ import { ARIARoleDefintionKey , roles } from 'aria-query' ;
26
27
27
28
const svg = / ^ (?: a l t G l y p h | a l t G l y p h D e f | a l t G l y p h I t e m | a n i m a t e | a n i m a t e C o l o r | a n i m a t e M o t i o n | a n i m a t e T r a n s f o r m | c i r c l e | c l i p P a t h | c o l o r - p r o f i l e | c u r s o r | d e f s | d e s c | d i s c a r d | e l l i p s e | f e B l e n d | f e C o l o r M a t r i x | f e C o m p o n e n t T r a n s f e r | f e C o m p o s i t e | f e C o n v o l v e M a t r i x | f e D i f f u s e L i g h t i n g | f e D i s p l a c e m e n t M a p | f e D i s t a n t L i g h t | f e D r o p S h a d o w | f e F l o o d | f e F u n c A | f e F u n c B | f e F u n c G | f e F u n c R | f e G a u s s i a n B l u r | f e I m a g e | f e M e r g e | f e M e r g e N o d e | f e M o r p h o l o g y | f e O f f s e t | f e P o i n t L i g h t | f e S p e c u l a r L i g h t i n g | f e S p o t L i g h t | f e T i l e | f e T u r b u l e n c e | f i l t e r | f o n t | f o n t - f a c e | f o n t - f a c e - f o r m a t | f o n t - f a c e - n a m e | f o n t - f a c e - s r c | f o n t - f a c e - u r i | f o r e i g n O b j e c t | g | g l y p h | g l y p h R e f | h a t c h | h a t c h p a t h | h k e r n | i m a g e | l i n e | l i n e a r G r a d i e n t | m a r k e r | m a s k | m e s h | m e s h g r a d i e n t | m e s h p a t c h | m e s h r o w | m e t a d a t a | m i s s i n g - g l y p h | m p a t h | p a t h | p a t t e r n | p o l y g o n | p o l y l i n e | r a d i a l G r a d i e n t | r e c t | s e t | s o l i d c o l o r | s t o p | s v g | s w i t c h | s y m b o l | t e x t | t e x t P a t h | t r e f | t s p a n | u n k n o w n | u s e | v i e w | v k e r n ) $ / ;
28
29
@@ -407,9 +408,9 @@ export default class Element extends Node {
407
408
}
408
409
409
410
validate_attributes_a11y ( ) {
410
- const { component } = this ;
411
+ const { component, attributes } = this ;
411
412
412
- this . attributes . forEach ( attribute => {
413
+ attributes . forEach ( attribute => {
413
414
if ( attribute . is_spread ) return ;
414
415
415
416
const name = attribute . name . toLowerCase ( ) ;
@@ -462,6 +463,17 @@ export default class Element extends Node {
462
463
component . warn ( attribute , compiler_warnings . a11y_no_redundant_roles ( value ) ) ;
463
464
}
464
465
}
466
+
467
+ // role-has-required-aria-props
468
+ const role = roles . get ( value as ARIARoleDefintionKey ) ;
469
+ if ( role ) {
470
+ const required_role_props = Object . keys ( role . requiredProps ) ;
471
+ const has_missing_props = required_role_props . some ( prop => ! attributes . find ( a => a . name === prop ) ) ;
472
+
473
+ if ( has_missing_props ) {
474
+ component . warn ( attribute , compiler_warnings . a11y_role_has_required_aria_props ( value as string , required_role_props ) ) ;
475
+ }
476
+ }
465
477
}
466
478
467
479
// no-access-key
0 commit comments