demo · v132

Dialog ToggleEvent — live listener

This page wires beforetoggle and toggle on a real <dialog>. Open and close it however you like (click, Escape, button) and watch the events stream in below with their oldState/newState.

checking support…

Hello! Close with Esc, the button, or the form below.

the code

dlg.addEventListener("beforetoggle", e => console.log("before:", e.oldState, "→", e.newState));
dlg.addEventListener("toggle",       e => console.log("toggle:", e.oldState, "→", e.newState));

see also