v136 · dom
'request-close' Invoker Command
Dialog elements can be closed through a variety of mechanisms, sometimes developers want to have the ability to prevent closure. To achieve this dialogs fire a cancel event. Originally this was only fired via a close request (e.g. ESC key press), recently a `requestClose()` JS function was added which also fires the cancel event. The 'request-close' comma
concepts
-
Dialog Cancel
request-close invoker command fires the dialog's cancel event before closing — declarative replacement for dialog.close() + cancel-event-dispatch.
-
Unsaved-changes confirmation
Real editor dialog: backdrop, Esc, and Cancel all funnel through one
cancelgate that pops a nested "discard?" sub-dialog when the form is dirty. -
Cancel Event Tracer
Every close path on a single dialog: ESC, backdrop,
close(),requestClose(), and bothcommand="close"/command="request-close"invokers. The log shows whethercancelfires beforeclose, and whetherpreventDefault()stops it. -
Multi-Dialog Stack
A 3-step wizard where every Cancel, back button, and Esc routes through
command="request-close". Onecancelhandler per step implements back-navigation without duplicating logic — and the event log shows exactly which event fired on each close path.
why it shipped
Invoker commands exposes existing dialog and popover functions to declarative HTML, for consistency we should also expose the new requestClose().