|
1 | 1 | // @ts-check |
2 | 2 |
|
3 | | -if (!("ariaNotify" in Element.prototype)) { |
| 3 | +if (!("ariaNotify" in Element.prototype) || !("ariaNotify" in Document.prototype)) { |
4 | 4 | /** @type {string} */ |
5 | 5 | let uniqueId = `${Date.now()}`; |
6 | 6 | try { |
@@ -166,15 +166,31 @@ if (!("ariaNotify" in Element.prototype)) { |
166 | 166 | } |
167 | 167 | customElements.define(liveRegionCustomElementName, LiveRegionCustomElement); |
168 | 168 |
|
169 | | - /** |
170 | | - * @param {string} message |
171 | | - * @param {object} options |
172 | | - * @param {"high" | "normal"} [options.priority] |
173 | | - */ |
174 | | - Element.prototype["ariaNotify"] = function ( |
175 | | - message, |
176 | | - { priority = "normal" } = {} |
177 | | - ) { |
178 | | - queue.enqueue(new Message({ element: this, message, priority })); |
179 | | - }; |
| 169 | + if (!("ariaNotify" in Element.prototype)) { |
| 170 | + /** |
| 171 | + * @param {string} message |
| 172 | + * @param {object} options |
| 173 | + * @param {"high" | "normal"} [options.priority] |
| 174 | + */ |
| 175 | + Element.prototype["ariaNotify"] = function ( |
| 176 | + message, |
| 177 | + { priority = "normal" } = {} |
| 178 | + ) { |
| 179 | + queue.enqueue(new Message({ element: this, message, priority })); |
| 180 | + }; |
| 181 | + } |
| 182 | + |
| 183 | + if (!("ariaNotify" in Document.prototype)) { |
| 184 | + /** |
| 185 | + * @param {string} message |
| 186 | + * @param {object} options |
| 187 | + * @param {"high" | "normal"} [options.priority] |
| 188 | + */ |
| 189 | + Document.prototype["ariaNotify"] = function ( |
| 190 | + message, |
| 191 | + { priority = "normal" } = {} |
| 192 | + ) { |
| 193 | + queue.enqueue(new Message({ element: this.documentElement, message, priority })); |
| 194 | + }; |
| 195 | + } |
180 | 196 | } |
0 commit comments