@@ -51,6 +51,74 @@ export const inheritAttributes = (el: HTMLElement, attributes: string[] = []) =>
51
51
return attributeObject ;
52
52
}
53
53
54
+ /**
55
+ * List of available ARIA attributes + `role`.
56
+ * Removed deprecated attributes.
57
+ * https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes
58
+ */
59
+ const ariaAttributes = [
60
+ 'role' ,
61
+ 'aria-activedescendant' ,
62
+ 'aria-atomic' ,
63
+ 'aria-autocomplete' ,
64
+ 'aria-braillelabel' ,
65
+ 'aria-brailleroledescription' ,
66
+ 'aria-busy' ,
67
+ 'aria-checked' ,
68
+ 'aria-colcount' ,
69
+ 'aria-colindex' ,
70
+ 'aria-colindextext' ,
71
+ 'aria-colspan' ,
72
+ 'aria-controls' ,
73
+ 'aria-current' ,
74
+ 'aria-describedby' ,
75
+ 'aria-description' ,
76
+ 'aria-details' ,
77
+ 'aria-disabled' ,
78
+ 'aria-errormessage' ,
79
+ 'aria-expanded' ,
80
+ 'aria-flowto' ,
81
+ 'aria-haspopup' ,
82
+ 'aria-hidden' ,
83
+ 'aria-invalid' ,
84
+ 'aria-keyshortcuts' ,
85
+ 'aria-label' ,
86
+ 'aria-labelledby' ,
87
+ 'aria-level' ,
88
+ 'aria-live' ,
89
+ 'aria-multiline' ,
90
+ 'aria-multiselectable' ,
91
+ 'aria-orientation' ,
92
+ 'aria-owns' ,
93
+ 'aria-placeholder' ,
94
+ 'aria-posinset' ,
95
+ 'aria-pressed' ,
96
+ 'aria-readonly' ,
97
+ 'aria-relevant' ,
98
+ 'aria-required' ,
99
+ 'aria-roledescription' ,
100
+ 'aria-rowcount' ,
101
+ 'aria-rowindex' ,
102
+ 'aria-rowindextext' ,
103
+ 'aria-rowspan' ,
104
+ 'aria-selected' ,
105
+ 'aria-setsize' ,
106
+ 'aria-sort' ,
107
+ 'aria-valuemax' ,
108
+ 'aria-valuemin' ,
109
+ 'aria-valuenow' ,
110
+ 'aria-valuetext' ,
111
+ ] ;
112
+
113
+ /**
114
+ * Returns an array of aria attributes that should be copied from
115
+ * the shadow host element to a target within the light DOM.
116
+ * @param el The element that the attributes should be copied from.
117
+ */
118
+ export const inheritAriaAttributes = ( el : HTMLElement ) => {
119
+ return inheritAttributes ( el , ariaAttributes ) ;
120
+ } ;
121
+
54
122
export const addEventListener = ( el : any , eventName : string , callback : any , opts ?: any ) => {
55
123
if ( typeof ( window as any ) !== 'undefined' ) {
56
124
const win = window as any ;
@@ -164,8 +232,8 @@ export const getAriaLabel = (componentEl: HTMLElement, inputId: string): { label
164
232
labelText = label . textContent ;
165
233
label . setAttribute ( 'aria-hidden' , 'true' ) ;
166
234
167
- // if there is no label, check to see if the user has provided
168
- // one by setting an id on the component and using the label element
235
+ // if there is no label, check to see if the user has provided
236
+ // one by setting an id on the component and using the label element
169
237
} else if ( componentId . trim ( ) !== '' ) {
170
238
label = document . querySelector ( `label[for="${ componentId } "]` ) ;
171
239
0 commit comments