WICG / close-watcher

A web API proposal for watching for close requests (e.g. Esc, Android back button, ...)
https://html.spec.whatwg.org/multipage/interaction.html#close-requests-and-close-watchers
71 stars 5 forks source link

HTML support for triggering close signal #26

Open tbondwilkinson opened 2 years ago

tbondwilkinson commented 2 years ago

The Popup API comes with new declarative triggering functionality on buttons for hiding and showing popups.

Should we support something similar for a generic connection to the CloseWatcher?

To enable this, you'd just need an id for the CloseWatcher that can be referenced in HTML.

domenic commented 2 years ago

Like #24 and #25, I feel that this kind of ask is against the current vision of CloseWatcher as a low-level primitive that you could use in a variety of ways, depending on your needs.

tbondwilkinson commented 2 years ago

I think that's a reasonable. My reason for asking is because I think there's real benefit in having HTML shorthands for what would otherwise only be possible in JavaScript. If we have to add any sugar, I think HTML-based sugar is the most desirable.

What if, for example, we had HTML-declarative mechanism for triggering custom events? In a framework, because of component boundaries, sometimes to get behavior you have to add a full JS controller or component to elements to trigger behavior. If you have a declarative method for doing that instead, you could skip attaching JS to that DOM element altogether.