@@ -116,6 +116,8 @@ class JoomlaDialog extends HTMLElement {
116
116
this . preferredParent = null ;
117
117
// @internal . Parent of the popupContent for cases when it is HTMLElement. Need for recovery on destroy().
118
118
this . popupContentSrcLocation = null ;
119
+ // @internal . Hold properties addressed directly to <dialog> element, like "aria-".
120
+ this . dialogProps = { } ;
119
121
120
122
if ( ! config ) return ;
121
123
@@ -127,6 +129,13 @@ class JoomlaDialog extends HTMLElement {
127
129
}
128
130
} ) ;
129
131
132
+ // Check for properties which should be applied to the <dialog> not to the <JoomlaDialog>, like "aria-".
133
+ [ 'ariaLabelledby' , 'ariaLabel' ] . forEach ( ( key ) => {
134
+ if ( config [ key ] !== undefined ) {
135
+ this . dialogProps [ key ] = config [ key ] ;
136
+ }
137
+ } ) ;
138
+
130
139
// Check class name
131
140
if ( config . className ) {
132
141
this . classList . add ( ...config . className . split ( ' ' ) ) ;
@@ -191,6 +200,11 @@ class JoomlaDialog extends HTMLElement {
191
200
this . dialog . addEventListener ( 'close' , onClose ) ;
192
201
this . appendChild ( this . dialog ) ;
193
202
203
+ // Apply dialog properties if any
204
+ Object . entries ( this . dialogProps ) . forEach ( ( [ k , v ] ) => {
205
+ this . dialog [ k ] = v ;
206
+ } ) ;
207
+
194
208
// Get template parts
195
209
this . popupTmplH = this . dialog . querySelector ( '.joomla-dialog-header' ) ;
196
210
this . popupTmplB = this . dialog . querySelector ( '.joomla-dialog-body' ) ;
@@ -214,6 +228,11 @@ class JoomlaDialog extends HTMLElement {
214
228
i . classList . add ( ...this . iconHeader . split ( ' ' ) ) ;
215
229
this . popupTmplH . insertAdjacentElement ( 'afterbegin' , i ) ;
216
230
}
231
+
232
+ // Set aria-label if it is still missing
233
+ if ( ! this . dialog . ariaLabel ) {
234
+ this . dialog . ariaLabel = this . textHeader ;
235
+ }
217
236
}
218
237
219
238
// Set the body
0 commit comments