Problem statement
Wire dismissible-dialog behaviour onto a set of pre-existing DOM elements using Vanilla TypeScript and standard DOM APIs. The page already renders the dialog markup — an opener button, a dialog (backdrop), a panel, and a close button — your job is to attach the event handling that opens, closes, and manages focus.
Demo
The page, styles, and dialog markup are already scaffolded and wired. Only the initializeDialog function is missing — implement it in src/dismissibleDialog.ts so every test passes. Do not edit any other file.
What to implement
- Open the dialog when the opener button is clicked, and move keyboard focus into the dialog.
- Close the dialog when the close button is clicked, when the
Escapekey is pressed, or when the backdrop (the dialog itself) is clicked. - Keep the dialog open when a click lands inside the panel.
- Return focus to the element that opened the dialog after closing.
- Register the
Escapekey listener only while the dialog is open, and remove it on close so a laterEscapepress does nothing. - Do not use global variables or recreate any DOM elements — only the supplied elements are modified.
