Comment by wizzwizz4

Comment by wizzwizz4 2 days ago

3 replies

The article says: “In its simplest form, you use it as in the following example:

  <permission type="camera" />
” but this isn't how HTML works. Really, while at first glance it might seem like a good idea, this whole feature is an inconsistent mess. It's not the declarative element it's claimed to be.
bastawhiz a day ago

Except it is declarative? The element renders a button and clicking the button (without any JavaScript) shows a browser UI for managing the permission. How is that imperative?

  • wizzwizz4 a day ago

    It's not declaring a permission: it's instructing the browser to render a button. That's like saying <button onclick="Notification.requestPermission()">Notify me!</button> is declarative.

    • bastawhiz a day ago

      It's declarative in that it's telling the browser to render a complete UI for showing and modifying the state of the permission. Just because there's also an imperative API that already exists doesn't mean it's not declarative. It's certainly not imperative, there's nothing imperative about it.

      Moreover, it allows the user to show the browser controls for re-requesting the permission if it was previously denied, which isn't possible with the imperative API (because an imperative API can implicitly be abused).