Skip to content

Commit c65b192

Browse files
authored
[5.3] Joomla Dialog add support for aria-label (#46090)
1 parent 2d01999 commit c65b192

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

build/media_source/system/js/joomla-dialog.w-c.es6.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ class JoomlaDialog extends HTMLElement {
116116
this.preferredParent = null;
117117
// @internal. Parent of the popupContent for cases when it is HTMLElement. Need for recovery on destroy().
118118
this.popupContentSrcLocation = null;
119+
// @internal. Hold properties addressed directly to <dialog> element, like "aria-".
120+
this.dialogProps = {};
119121

120122
if (!config) return;
121123

@@ -127,6 +129,13 @@ class JoomlaDialog extends HTMLElement {
127129
}
128130
});
129131

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+
130139
// Check class name
131140
if (config.className) {
132141
this.classList.add(...config.className.split(' '));
@@ -191,6 +200,11 @@ class JoomlaDialog extends HTMLElement {
191200
this.dialog.addEventListener('close', onClose);
192201
this.appendChild(this.dialog);
193202

203+
// Apply dialog properties if any
204+
Object.entries(this.dialogProps).forEach(([k, v]) => {
205+
this.dialog[k] = v;
206+
});
207+
194208
// Get template parts
195209
this.popupTmplH = this.dialog.querySelector('.joomla-dialog-header');
196210
this.popupTmplB = this.dialog.querySelector('.joomla-dialog-body');
@@ -214,6 +228,11 @@ class JoomlaDialog extends HTMLElement {
214228
i.classList.add(...this.iconHeader.split(' '));
215229
this.popupTmplH.insertAdjacentElement('afterbegin', i);
216230
}
231+
232+
// Set aria-label if it is still missing
233+
if (!this.dialog.ariaLabel) {
234+
this.dialog.ariaLabel = this.textHeader;
235+
}
217236
}
218237

219238
// Set the body

0 commit comments

Comments
 (0)