← Back to release summary

Dialog Toggle Events

Category
DOM
Type
New or changed feature
Status
Enabled by default (Chrome 132)
Intent stage
None

Summary

It is useful for web authors do determine when their <dialog> elements open and close. popover already has `ToggleEvent` which is dispatched when a popover opens or closes, but <dialog> does not. The current way to detect when a <dialog> opens is to register a mutation observer to check for open, however, this is quite a lot of work where an event would be easier. This change incorporates the same `ToggleEvent`s that popovers dispatch, but for `<dialog>` elements: when `showModal` or `show` is called, <dialog> dispatches a ToggleEvent with newState=open. When a dialog is closed (via form or button or closewatcher) it should dispatch a ToggleEvent with newState=closed.

Standards & signals

View on chromestatus.com