@@ -672,15 +672,6 @@ function check_element(node, state) {
672
672
// foreign namespace means elements can have completely different meanings, therefore we don't check them
673
673
if ( state . options . namespace === 'foreign' ) return ;
674
674
675
- /**
676
- * @template {keyof import('../../warnings-tmp.js').AllWarnings} T
677
- * @param {{ start?: number, end?: number } } node
678
- * @param {T } code
679
- * @param {Parameters<import('../../warnings-tmp.js').AllWarnings[T]> } args
680
- * @returns {void }
681
- */
682
- const push_warning = ( node , code , ...args ) => warn ( state . analysis . warnings , node , code , ...args ) ;
683
-
684
675
/** @type {Map<string, import('#compiler').Attribute> } */
685
676
const attribute_map = new Map ( ) ;
686
677
@@ -727,17 +718,17 @@ function check_element(node, state) {
727
718
if ( name . startsWith ( 'aria-' ) ) {
728
719
if ( invisible_elements . includes ( node . name ) ) {
729
720
// aria-unsupported-elements
730
- push_warning ( attribute , 'a11y-aria-attributes' , node . name ) ;
721
+ warn ( attribute , 'a11y-aria-attributes' , node . name ) ;
731
722
}
732
723
733
724
const type = name . slice ( 5 ) ;
734
725
if ( ! aria_attributes . includes ( type ) ) {
735
726
const match = fuzzymatch ( type , aria_attributes ) ;
736
- push_warning ( attribute , 'a11y-unknown-aria-attribute' , type , match ) ;
727
+ warn ( attribute , 'a11y-unknown-aria-attribute' , type , match ) ;
737
728
}
738
729
739
730
if ( name === 'aria-hidden' && regex_heading_tags . test ( node . name ) ) {
740
- push_warning ( attribute , 'a11y-hidden' , node . name ) ;
731
+ warn ( attribute , 'a11y-hidden' , node . name ) ;
741
732
}
742
733
743
734
// aria-proptypes
@@ -747,7 +738,7 @@ function check_element(node, state) {
747
738
if ( value !== null && value !== undefined ) {
748
739
const schema = aria . get ( /** @type {import('aria-query').ARIAProperty } */ ( name ) ) ;
749
740
if ( schema !== undefined && ! is_valid_aria_attribute_value ( schema , value ) ) {
750
- push_warning ( attribute , 'a11y-incorrect-aria-attribute-type' , schema , name ) ;
741
+ warn ( attribute , 'a11y-incorrect-aria-attribute-type' , schema , name ) ;
751
742
}
752
743
}
753
744
@@ -758,15 +749,15 @@ function check_element(node, state) {
758
749
! is_interactive_element ( node . name , attribute_map ) &&
759
750
! attribute_map . has ( 'tabindex' )
760
751
) {
761
- push_warning ( attribute , 'a11y-aria-activedescendant-has-tabindex' ) ;
752
+ warn ( attribute , 'a11y-aria-activedescendant-has-tabindex' ) ;
762
753
}
763
754
}
764
755
765
756
// aria-role
766
757
if ( name === 'role' ) {
767
758
if ( invisible_elements . includes ( node . name ) ) {
768
759
// aria-unsupported-elements
769
- push_warning ( attribute , 'a11y-misplaced-role' , node . name ) ;
760
+ warn ( attribute , 'a11y-misplaced-role' , node . name ) ;
770
761
}
771
762
772
763
const value = get_static_value ( attribute ) ;
@@ -776,10 +767,10 @@ function check_element(node, state) {
776
767
/** @type {import('aria-query').ARIARoleDefinitionKey } current_role */ ( c_r ) ;
777
768
778
769
if ( current_role && is_abstract_role ( current_role ) ) {
779
- push_warning ( attribute , 'a11y-no-abstract-role' , current_role ) ;
770
+ warn ( attribute , 'a11y-no-abstract-role' , current_role ) ;
780
771
} else if ( current_role && ! aria_roles . includes ( current_role ) ) {
781
772
const match = fuzzymatch ( current_role , aria_roles ) ;
782
- push_warning ( attribute , 'a11y-unknown-role' , current_role , match ) ;
773
+ warn ( attribute , 'a11y-unknown-role' , current_role , match ) ;
783
774
}
784
775
785
776
// no-redundant-roles
@@ -788,7 +779,7 @@ function check_element(node, state) {
788
779
// <ul role="list"> is ok because CSS list-style:none removes the semantics and this is a way to bring them back
789
780
! [ 'ul' , 'ol' , 'li' ] . includes ( node . name )
790
781
) {
791
- push_warning ( attribute , 'a11y-no-redundant-roles' , current_role ) ;
782
+ warn ( attribute , 'a11y-no-redundant-roles' , current_role ) ;
792
783
}
793
784
794
785
// Footers and headers are special cases, and should not have redundant roles unless they are the children of sections or articles.
@@ -797,7 +788,7 @@ function check_element(node, state) {
797
788
const has_nested_redundant_role =
798
789
current_role === a11y_nested_implicit_semantics . get ( node . name ) ;
799
790
if ( has_nested_redundant_role ) {
800
- push_warning ( attribute , 'a11y-no-redundant-roles' , current_role ) ;
791
+ warn ( attribute , 'a11y-no-redundant-roles' , current_role ) ;
801
792
}
802
793
}
803
794
@@ -813,7 +804,7 @@ function check_element(node, state) {
813
804
( prop ) => ! attributes . find ( ( a ) => a . name === prop )
814
805
) ;
815
806
if ( has_missing_props ) {
816
- push_warning (
807
+ warn (
817
808
attribute ,
818
809
'a11y-role-has-required-aria-props' ,
819
810
current_role ,
@@ -836,7 +827,7 @@ function check_element(node, state) {
836
827
a11y_interactive_handlers . includes ( handler )
837
828
) ;
838
829
if ( has_interactive_handlers ) {
839
- push_warning ( node , 'a11y-interactive-supports-focus' , current_role ) ;
830
+ warn ( node , 'a11y-interactive-supports-focus' , current_role ) ;
840
831
}
841
832
}
842
833
@@ -845,7 +836,7 @@ function check_element(node, state) {
845
836
is_interactive_element ( node . name , attribute_map ) &&
846
837
( is_non_interactive_roles ( current_role ) || is_presentation_role ( current_role ) )
847
838
) {
848
- push_warning (
839
+ warn (
849
840
node ,
850
841
'a11y-no-interactive-element-to-noninteractive-role' ,
851
842
current_role ,
@@ -861,7 +852,7 @@ function check_element(node, state) {
861
852
current_role
862
853
)
863
854
) {
864
- push_warning (
855
+ warn (
865
856
node ,
866
857
'a11y-no-noninteractive-element-to-interactive-role' ,
867
858
current_role ,
@@ -874,25 +865,25 @@ function check_element(node, state) {
874
865
875
866
// no-access-key
876
867
if ( name === 'accesskey' ) {
877
- push_warning ( attribute , 'a11y-accesskey' ) ;
868
+ warn ( attribute , 'a11y-accesskey' ) ;
878
869
}
879
870
880
871
// no-autofocus
881
872
if ( name === 'autofocus' ) {
882
- push_warning ( attribute , 'a11y-autofocus' ) ;
873
+ warn ( attribute , 'a11y-autofocus' ) ;
883
874
}
884
875
885
876
// scope
886
877
if ( name === 'scope' && ! is_dynamic_element && node . name !== 'th' ) {
887
- push_warning ( attribute , 'a11y-misplaced-scope' ) ;
878
+ warn ( attribute , 'a11y-misplaced-scope' ) ;
888
879
}
889
880
890
881
// tabindex-no-positive
891
882
if ( name === 'tabindex' ) {
892
883
const value = get_static_value ( attribute ) ;
893
884
// @ts -ignore todo is tabindex=true correct case?
894
885
if ( ! isNaN ( value ) && + value > 0 ) {
895
- push_warning ( attribute , 'a11y-positive-tabindex' ) ;
886
+ warn ( attribute , 'a11y-positive-tabindex' ) ;
896
887
}
897
888
}
898
889
}
@@ -916,7 +907,7 @@ function check_element(node, state) {
916
907
const has_key_event =
917
908
handlers . has ( 'keydown' ) || handlers . has ( 'keyup' ) || handlers . has ( 'keypress' ) ;
918
909
if ( ! has_key_event ) {
919
- push_warning ( node , 'a11y-click-events-have-key-events' ) ;
910
+ warn ( node , 'a11y-click-events-have-key-events' ) ;
920
911
}
921
912
}
922
913
}
@@ -934,7 +925,7 @@ function check_element(node, state) {
934
925
const tab_index = attribute_map . get ( 'tabindex' ) ;
935
926
const tab_index_value = get_static_text_value ( tab_index ) ;
936
927
if ( tab_index && ( tab_index_value === null || Number ( tab_index_value ) >= 0 ) ) {
937
- push_warning ( node , 'a11y-no-noninteractive-tabindex' ) ;
928
+ warn ( node , 'a11y-no-noninteractive-tabindex' ) ;
938
929
}
939
930
}
940
931
@@ -949,14 +940,7 @@ function check_element(node, state) {
949
940
if (
950
941
invalid_aria_props . includes ( /** @type {import('aria-query').ARIAProperty } */ ( attr . name ) )
951
942
) {
952
- push_warning (
953
- attr ,
954
- 'a11y-role-supports-aria-props' ,
955
- attr . name ,
956
- role_value ,
957
- is_implicit ,
958
- node . name
959
- ) ;
943
+ warn ( attr , 'a11y-role-supports-aria-props' , attr . name , role_value , is_implicit , node . name ) ;
960
944
}
961
945
}
962
946
}
@@ -974,7 +958,7 @@ function check_element(node, state) {
974
958
a11y_recommended_interactive_handlers . includes ( handler )
975
959
) ;
976
960
if ( has_interactive_handlers ) {
977
- push_warning ( node , 'a11y-no-noninteractive-element-interactions' , node . name ) ;
961
+ warn ( node , 'a11y-no-noninteractive-element-interactions' , node . name ) ;
978
962
}
979
963
}
980
964
@@ -993,16 +977,16 @@ function check_element(node, state) {
993
977
a11y_interactive_handlers . includes ( handler )
994
978
) ;
995
979
if ( interactive_handlers . length > 0 ) {
996
- push_warning ( node , 'a11y-no-static-element-interactions' , node . name , interactive_handlers ) ;
980
+ warn ( node , 'a11y-no-static-element-interactions' , node . name , interactive_handlers ) ;
997
981
}
998
982
}
999
983
1000
984
if ( handlers . has ( 'mouseover' ) && ! handlers . has ( 'focus' ) ) {
1001
- push_warning ( node , 'a11y-mouse-events-have-key-events' , 'mouseover' , 'focus' ) ;
985
+ warn ( node , 'a11y-mouse-events-have-key-events' , 'mouseover' , 'focus' ) ;
1002
986
}
1003
987
1004
988
if ( handlers . has ( 'mouseout' ) && ! handlers . has ( 'blur' ) ) {
1005
- push_warning ( node , 'a11y-mouse-events-have-key-events' , 'mouseout' , 'blur' ) ;
989
+ warn ( node , 'a11y-mouse-events-have-key-events' , 'mouseout' , 'blur' ) ;
1006
990
}
1007
991
1008
992
// element-specific checks
@@ -1021,22 +1005,22 @@ function check_element(node, state) {
1021
1005
const href_value = get_static_text_value ( href ) ;
1022
1006
if ( href_value !== null ) {
1023
1007
if ( href_value === '' || href_value === '#' || / ^ \W * j a v a s c r i p t : / i. test ( href_value ) ) {
1024
- push_warning ( href , 'a11y-invalid-attribute' , href . name , href_value ) ;
1008
+ warn ( href , 'a11y-invalid-attribute' , href . name , href_value ) ;
1025
1009
}
1026
1010
}
1027
1011
} else if ( ! has_spread ) {
1028
1012
const id_attribute = get_static_value ( attribute_map . get ( 'id' ) ) ;
1029
1013
const name_attribute = get_static_value ( attribute_map . get ( 'name' ) ) ;
1030
1014
if ( ! id_attribute && ! name_attribute ) {
1031
- push_warning ( ...warn_missing_attribute ( node , [ 'href' ] ) ) ;
1015
+ warn ( ...warn_missing_attribute ( node , [ 'href' ] ) ) ;
1032
1016
}
1033
1017
}
1034
1018
} else if ( ! has_spread ) {
1035
1019
const required_attributes = a11y_required_attributes [ node . name ] ;
1036
1020
if ( required_attributes ) {
1037
1021
const has_attribute = required_attributes . some ( ( name ) => attribute_map . has ( name ) ) ;
1038
1022
if ( ! has_attribute ) {
1039
- push_warning ( ...warn_missing_attribute ( node , required_attributes ) ) ;
1023
+ warn ( ...warn_missing_attribute ( node , required_attributes ) ) ;
1040
1024
}
1041
1025
}
1042
1026
}
@@ -1048,15 +1032,15 @@ function check_element(node, state) {
1048
1032
const required_attributes = [ 'alt' , 'aria-label' , 'aria-labelledby' ] ;
1049
1033
const has_attribute = required_attributes . some ( ( name ) => attribute_map . has ( name ) ) ;
1050
1034
if ( ! has_attribute ) {
1051
- push_warning ( ...warn_missing_attribute ( node , required_attributes , 'input type="image"' ) ) ;
1035
+ warn ( ...warn_missing_attribute ( node , required_attributes , 'input type="image"' ) ) ;
1052
1036
}
1053
1037
}
1054
1038
// autocomplete-valid
1055
1039
const autocomplete = attribute_map . get ( 'autocomplete' ) ;
1056
1040
if ( type && autocomplete ) {
1057
1041
const autocomplete_value = get_static_value ( autocomplete ) ;
1058
1042
if ( ! is_valid_autocomplete ( autocomplete_value ) ) {
1059
- push_warning ( autocomplete , 'a11y-autocomplete-valid' , type_value , autocomplete_value ) ;
1043
+ warn ( autocomplete , 'a11y-autocomplete-valid' , type_value , autocomplete_value ) ;
1060
1044
}
1061
1045
}
1062
1046
}
@@ -1066,7 +1050,7 @@ function check_element(node, state) {
1066
1050
const aria_hidden = get_static_value ( attribute_map . get ( 'aria-hidden' ) ) ;
1067
1051
if ( alt_attribute && ! aria_hidden ) {
1068
1052
if ( / \b ( i m a g e | p i c t u r e | p h o t o ) \b / i. test ( alt_attribute ) ) {
1069
- push_warning ( node , 'a11y-img-redundant-alt' ) ;
1053
+ warn ( node , 'a11y-img-redundant-alt' ) ;
1070
1054
}
1071
1055
}
1072
1056
}
@@ -1096,7 +1080,7 @@ function check_element(node, state) {
1096
1080
return has ;
1097
1081
} ;
1098
1082
if ( ! attribute_map . has ( 'for' ) && ! has_input_child ( node ) ) {
1099
- push_warning ( node , 'a11y-label-has-associated-control' ) ;
1083
+ warn ( node , 'a11y-label-has-associated-control' ) ;
1100
1084
}
1101
1085
}
1102
1086
@@ -1118,13 +1102,13 @@ function check_element(node, state) {
1118
1102
) ;
1119
1103
}
1120
1104
if ( ! has_caption ) {
1121
- push_warning ( node , 'a11y-media-has-caption' ) ;
1105
+ warn ( node , 'a11y-media-has-caption' ) ;
1122
1106
}
1123
1107
}
1124
1108
1125
1109
if ( node . name === 'figcaption' ) {
1126
1110
if ( ! is_parent ( node . parent , [ 'figure' ] ) ) {
1127
- push_warning ( node , 'a11y-structure' , true ) ;
1111
+ warn ( node , 'a11y-structure' , true ) ;
1128
1112
}
1129
1113
}
1130
1114
@@ -1138,13 +1122,13 @@ function check_element(node, state) {
1138
1122
( child ) => child . type === 'RegularElement' && child . name === 'figcaption'
1139
1123
) ;
1140
1124
if ( index !== - 1 && index !== 0 && index !== children . length - 1 ) {
1141
- push_warning ( children [ index ] , 'a11y-structure' , false ) ;
1125
+ warn ( children [ index ] , 'a11y-structure' , false ) ;
1142
1126
}
1143
1127
}
1144
1128
1145
1129
if ( a11y_distracting_elements . includes ( node . name ) ) {
1146
1130
// no-distracting-elements
1147
- push_warning ( node , 'a11y-distracting-elements' , node . name ) ;
1131
+ warn ( node , 'a11y-distracting-elements' , node . name ) ;
1148
1132
}
1149
1133
1150
1134
// Check content
@@ -1154,7 +1138,7 @@ function check_element(node, state) {
1154
1138
a11y_required_content . includes ( node . name ) &&
1155
1139
node . fragment . nodes . length === 0
1156
1140
) {
1157
- push_warning ( node , 'a11y-missing-content' , node . name ) ;
1141
+ warn ( node , 'a11y-missing-content' , node . name ) ;
1158
1142
}
1159
1143
}
1160
1144
0 commit comments