@@ -31,42 +31,19 @@ if (!("ariaNotify" in Element.prototype)) {
3131 /** @type {string } */
3232 message ;
3333
34- /** @type {"important" | "none" } */
35- priority = "none" ;
36-
37- /** @type {"all" | "pending" | "none" } */
38- interrupt = "none" ;
39-
40- /** @type {boolean } */
41- get #shouldFlushOthers( ) {
42- return this . interrupt === "all" || this . interrupt === "pending" ;
43- }
34+ /** @type {"high" | "normal" } */
35+ priority = "normal" ;
4436
4537 /**
4638 * @param {object } message
4739 * @param {Element } message.element
4840 * @param {string } message.message
49- * @param {"important" | "none" } message.priority
50- * @param {"all" | "pending" | "none" } message.interrupt
41+ * @param {"high" | "normal" } message.priority
5142 */
52- constructor ( { element, message, priority = "none" , interrupt = "none " } ) {
43+ constructor ( { element, message, priority = "normal " } ) {
5344 this . element = element ;
5445 this . message = message ;
5546 this . priority = priority ;
56- this . interrupt = interrupt ;
57- }
58-
59- /**
60- * Whether this message and the given message are equivalent.
61- * @param {Message } message
62- * @returns {boolean }
63- */
64- matches ( message ) {
65- return (
66- this . element === message . element &&
67- this . priority === message . priority &&
68- this . interrupt === message . interrupt
69- ) ;
7047 }
7148
7249 /**
@@ -104,12 +81,6 @@ if (!("ariaNotify" in Element.prototype)) {
10481 /** @type {LiveRegionCustomElement | null } */
10582 let liveRegion = root . querySelector ( liveRegionCustomElementName ) ;
10683
107- // Destroy 'live-region', if it exists and should be flushed
108- if ( this . #shouldFlushOthers && liveRegion ) {
109- liveRegion . remove ( ) ;
110- liveRegion = null ;
111- }
112-
11384 // Create (or recreate) 'live-region', if it doesn’t exist
11485 if ( ! liveRegion ) {
11586 liveRegion = /** @type {LiveRegionCustomElement } */ (
@@ -136,22 +107,15 @@ if (!("ariaNotify" in Element.prototype)) {
136107 * @returns {void }
137108 */
138109 enqueue ( message ) {
139- const { priority, interrupt } = message ;
140-
141- if ( interrupt === "all" || interrupt === "pending" ) {
142- // Remove other messages with the same element, priority, and interrupt
143- this . #queue = this . #queue. filter (
144- ( message ) => ! message . matches ( message )
145- ) ;
146- }
110+ const { priority } = message ;
147111
148- if ( priority === "important " ) {
149- // Insert after the last important message, or at the beginning
112+ if ( priority === "high " ) {
113+ // Insert after the last high-priority message, or at the beginning
150114 // @ts -ignore: ts(2550)
151- const lastImportantMessage = this . #queue. findLastIndex (
152- ( message ) => message . priority === "important "
115+ const lastHighPriorityMessage = this . #queue. findLastIndex (
116+ ( message ) => message . priority === "high "
153117 ) ;
154- this . #queue. splice ( lastImportantMessage + 1 , 0 , message ) ;
118+ this . #queue. splice ( lastHighPriorityMessage + 1 , 0 , message ) ;
155119 } else {
156120 // Insert at the end
157121 this . #queue. push ( message ) ;
@@ -205,13 +169,12 @@ if (!("ariaNotify" in Element.prototype)) {
205169 /**
206170 * @param {string } message
207171 * @param {object } options
208- * @param {"important" | "none" } [options.priority]
209- * @param {"all" | "pending" | "none" } [options.interrupt]
172+ * @param {"high" | "normal" } [options.priority]
210173 */
211174 Element . prototype [ "ariaNotify" ] = function (
212175 message ,
213- { priority = "none" , interrupt = "none " } = { }
176+ { priority = "normal " } = { }
214177 ) {
215- queue . enqueue ( new Message ( { element : this , message, priority, interrupt } ) ) ;
178+ queue . enqueue ( new Message ( { element : this , message, priority } ) ) ;
216179 } ;
217180}
0 commit comments