| ... |
... |
@@ -65,8 +65,9 @@ export default class MozMessageBar extends MozLitElement { |
|
65
|
65
|
supportPage: { type: String },
|
|
66
|
66
|
messageL10nId: { type: String },
|
|
67
|
67
|
messageL10nArgs: { type: String },
|
|
68
|
|
- role: { type: String, reflect: true },
|
|
69
|
|
- useAlertRole: { type: Boolean },
|
|
|
68
|
+ // Move the role from the widget to its shadow root, where we can apply
|
|
|
69
|
+ // aria-labelledby and aria-describedby. tor-browser#45186.
|
|
|
70
|
+ role: { type: String, mapped: true },
|
|
70
|
71
|
};
|
|
71
|
72
|
|
|
72
|
73
|
constructor() {
|
| ... |
... |
@@ -127,8 +128,6 @@ export default class MozMessageBar extends MozLitElement { |
|
127
|
128
|
* @type {string}
|
|
128
|
129
|
*/
|
|
129
|
130
|
this.role = "alert";
|
|
130
|
|
-
|
|
131
|
|
- this.useAlertRole = true;
|
|
132
|
131
|
}
|
|
133
|
132
|
|
|
134
|
133
|
onActionSlotchange() {
|
| ... |
... |
@@ -170,17 +169,6 @@ export default class MozMessageBar extends MozLitElement { |
|
170
|
169
|
></slot>`;
|
|
171
|
170
|
}
|
|
172
|
171
|
|
|
173
|
|
- setAlertRole() {
|
|
174
|
|
- // Wait a little for this to render before setting the role for more
|
|
175
|
|
- // consistent alerts to screen readers.
|
|
176
|
|
- this.useAlertRole = false;
|
|
177
|
|
- window.requestAnimationFrame(() => {
|
|
178
|
|
- window.requestAnimationFrame(() => {
|
|
179
|
|
- this.useAlertRole = true;
|
|
180
|
|
- });
|
|
181
|
|
- });
|
|
182
|
|
- }
|
|
183
|
|
-
|
|
184
|
172
|
iconTemplate() {
|
|
185
|
173
|
let iconData = messageTypeToIconData[this.type];
|
|
186
|
174
|
if (iconData) {
|
| ... |
... |
@@ -224,6 +212,16 @@ export default class MozMessageBar extends MozLitElement { |
|
224
|
212
|
}
|
|
225
|
213
|
|
|
226
|
214
|
render() {
|
|
|
215
|
+ let ariaLabelledBy;
|
|
|
216
|
+ let ariaDescribedBy;
|
|
|
217
|
+ if (this.role === "alert") {
|
|
|
218
|
+ if (this.heading) {
|
|
|
219
|
+ ariaLabelledBy = "heading";
|
|
|
220
|
+ ariaDescribedBy = "content";
|
|
|
221
|
+ } else {
|
|
|
222
|
+ ariaLabelledBy = "content";
|
|
|
223
|
+ }
|
|
|
224
|
+ }
|
|
227
|
225
|
return html`
|
|
228
|
226
|
<link
|
|
229
|
227
|
rel="stylesheet"
|
| ... |
... |
@@ -231,9 +229,9 @@ export default class MozMessageBar extends MozLitElement { |
|
231
|
229
|
/>
|
|
232
|
230
|
<div
|
|
233
|
231
|
class="container"
|
|
234
|
|
- role=${ifDefined(this.useAlertRole ? "alert" : undefined)}
|
|
235
|
|
- aria-labelledby=${this.heading ? "heading" : "content"}
|
|
236
|
|
- aria-describedby=${ifDefined(this.heading ? "content" : undefined)}
|
|
|
232
|
+ role=${ifDefined(this.role || undefined)}
|
|
|
233
|
+ aria-labelledby=${ifDefined(ariaLabelledBy)}
|
|
|
234
|
+ aria-describedby=${ifDefined(ariaDescribedBy)}
|
|
237
|
235
|
>
|
|
238
|
236
|
${this.iconTemplate()}
|
|
239
|
237
|
<div class="content">
|