demo · v139
Dialog Cancel Button
Open the dialog, then click "Cancel". The button uses command="request-close" — declaratively firing the cancel event before closing. Watch the log on the right.
Your browser does not yet support the request-close command. Click the button anyway — the demo falls back to dialog.close().
the html
<button commandfor="dlg" command="request-close">Cancel</button>
<dialog id="dlg">
<p>Are you sure?</p>
</dialog>