|
275 | 275 | other_popover.showPopover();
|
276 | 276 | const popover = createPopover(t);
|
277 | 277 | popover.setAttribute('popover','auto');
|
278 |
| - other_popover.addEventListener('toggle', (e) => { |
279 |
| - if (e.state !== "closing") return; |
| 278 | + other_popover.addEventListener('beforetoggle', (e) => { |
| 279 | + if (e.newState !== "closed") |
| 280 | + return; |
280 | 281 | popover.setAttribute('popover','manual');
|
281 | 282 | },{once: true});
|
282 | 283 | assert_true(other_popover.matches(':open'));
|
283 | 284 | assert_false(popover.matches(':open'));
|
284 | 285 | popover.showPopover();
|
285 | 286 | assert_false(other_popover.matches(':open'),'unrelated popover is hidden');
|
286 | 287 | assert_false(popover.matches(':open'),'popover is not shown if its type changed during show');
|
287 |
| - },`Changing the popover type in a "toggle" event handler should not cause problems (during showPopover())`); |
| 288 | + },`Changing the popover type in a "beforetoggle" event handler should not cause problems (during showPopover())`); |
288 | 289 |
|
289 | 290 | test((t) => {
|
290 | 291 | const popover = createPopover(t);
|
|
295 | 296 | popover.showPopover();
|
296 | 297 | other_popover.showPopover();
|
297 | 298 | let nested_popover_hidden=false;
|
298 |
| - other_popover.addEventListener('toggle', (e) => { |
299 |
| - if (e.state !== "closing") return; |
| 299 | + other_popover.addEventListener('beforetoggle', (e) => { |
| 300 | + if (e.newState !== "closed") |
| 301 | + return; |
300 | 302 | nested_popover_hidden = true;
|
301 | 303 | popover.setAttribute('popover','manual');
|
302 | 304 | },{once: true});
|
303 |
| - popover.addEventListener('toggle', (e) => { |
304 |
| - if (e.state !== "closing") return; |
| 305 | + popover.addEventListener('beforetoggle', (e) => { |
| 306 | + if (e.newState !== "closed") |
| 307 | + return; |
305 | 308 | assert_true(nested_popover_hidden,'The nested popover should be hidden first');
|
306 | 309 | },{once: true});
|
307 | 310 | assert_true(popover.matches(':open'));
|
|
310 | 313 | assert_false(other_popover.matches(':open'),'unrelated popover is hidden');
|
311 | 314 | assert_false(popover.matches(':open'),'popover is still hidden if its type changed during hide event');
|
312 | 315 | assert_throws_dom("InvalidStateError",() => other_popover.hidePopover(),'Nested popover should already be hidden');
|
313 |
| - },`Changing the popover type in a "toggle" event handler should not cause problems (during hidePopover())`); |
| 316 | + },`Changing the popover type in a "beforetoggle" event handler should not cause problems (during hidePopover())`); |
314 | 317 |
|
315 | 318 | function interpretedType(typeString,method) {
|
316 | 319 | if (validTypes.includes(typeString))
|
|
347 | 350 | popover.showPopover();
|
348 | 351 | assert_true(popover.matches(':open'));
|
349 | 352 | let gotEvent = false;
|
350 |
| - popover.addEventListener('toggle', (e) => { |
351 |
| - if (e.state !== "closing") return; |
| 353 | + popover.addEventListener('beforetoggle', (e) => { |
| 354 | + if (e.newState !== "closed") |
| 355 | + return; |
352 | 356 | gotEvent = true;
|
353 | 357 | setPopoverValue(popover,inEventType,method);
|
354 | 358 | },{once:true});
|
|
384 | 388 | }
|
385 | 389 | }
|
386 | 390 | }
|
387 |
| - },`Changing a popover from ${type} to ${newType} (via ${method}), and then ${inEventType} during 'toggle' works`); |
| 391 | + },`Changing a popover from ${type} to ${newType} (via ${method}), and then ${inEventType} during 'beforetoggle' works`); |
388 | 392 | });
|
389 | 393 | });
|
390 | 394 | });
|
|
0 commit comments