@@ -31,42 +31,19 @@ if (!("ariaNotify" in Element.prototype)) {
31
31
/** @type {string } */
32
32
message ;
33
33
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" ;
44
36
45
37
/**
46
38
* @param {object } message
47
39
* @param {Element } message.element
48
40
* @param {string } message.message
49
- * @param {"important" | "none" } message.priority
50
- * @param {"all" | "pending" | "none" } message.interrupt
41
+ * @param {"high" | "normal" } message.priority
51
42
*/
52
- constructor ( { element, message, priority = "none" , interrupt = "none " } ) {
43
+ constructor ( { element, message, priority = "normal " } ) {
53
44
this . element = element ;
54
45
this . message = message ;
55
46
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
- ) ;
70
47
}
71
48
72
49
/**
@@ -104,12 +81,6 @@ if (!("ariaNotify" in Element.prototype)) {
104
81
/** @type {LiveRegionCustomElement | null } */
105
82
let liveRegion = root . querySelector ( liveRegionCustomElementName ) ;
106
83
107
- // Destroy 'live-region', if it exists and should be flushed
108
- if ( this . #shouldFlushOthers && liveRegion ) {
109
- liveRegion . remove ( ) ;
110
- liveRegion = null ;
111
- }
112
-
113
84
// Create (or recreate) 'live-region', if it doesn’t exist
114
85
if ( ! liveRegion ) {
115
86
liveRegion = /** @type {LiveRegionCustomElement } */ (
@@ -136,22 +107,15 @@ if (!("ariaNotify" in Element.prototype)) {
136
107
* @returns {void }
137
108
*/
138
109
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 ;
147
111
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
150
114
// @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 "
153
117
) ;
154
- this . #queue. splice ( lastImportantMessage + 1 , 0 , message ) ;
118
+ this . #queue. splice ( lastHighPriorityMessage + 1 , 0 , message ) ;
155
119
} else {
156
120
// Insert at the end
157
121
this . #queue. push ( message ) ;
@@ -205,13 +169,12 @@ if (!("ariaNotify" in Element.prototype)) {
205
169
/**
206
170
* @param {string } message
207
171
* @param {object } options
208
- * @param {"important" | "none" } [options.priority]
209
- * @param {"all" | "pending" | "none" } [options.interrupt]
172
+ * @param {"high" | "normal" } [options.priority]
210
173
*/
211
174
Element . prototype [ "ariaNotify" ] = function (
212
175
message ,
213
- { priority = "none" , interrupt = "none " } = { }
176
+ { priority = "normal " } = { }
214
177
) {
215
- queue . enqueue ( new Message ( { element : this , message, priority, interrupt } ) ) ;
178
+ queue . enqueue ( new Message ( { element : this , message, priority } ) ) ;
216
179
} ;
217
180
}
0 commit comments