The close action for the CloseWatcher class's close watcher is to signal close. The close action for the <dialog> element's close watcher is to cancel the dialog.
These two close actions consist of very similar steps. Roughly:
If allowed to do so,
Fire a cancel event on the object
Consume the user-activation-for-close-watchers
Bail out if the cancel event was canceled
Do actual closing stuff
We can probably move this infrastructure into the conceptual close watcher, by giving them "cancel actions" and "close actions", and then wrapping up that logic. This better ensures that all close watcher users actually do the correct thing with regard to checking whether cancel steps are allowed and consuming the user activation. And it makes it easier to write any future specs that use close watchers.
In https://chromium-review.googlesource.com/c/chromium/src/+/3502624 @josepharhar stumbled across a mismatch between implementation and spec techniques that made me think we could improve the spec.
In particular, right now conceptual close watchers have close actions.
The close action for the
CloseWatcher
class's close watcher is to signal close. The close action for the<dialog>
element's close watcher is to cancel the dialog.These two close actions consist of very similar steps. Roughly:
We can probably move this infrastructure into the conceptual close watcher, by giving them "cancel actions" and "close actions", and then wrapping up that logic. This better ensures that all close watcher users actually do the correct thing with regard to checking whether cancel steps are allowed and consuming the user activation. And it makes it easier to write any future specs that use close watchers.