[w3c/permissions] PermissionStatus should have a `name` (#237)

`PermissionStatus` should expose the `.name` of the status it's holding the permission for. Otherwise, the developer is forced to independently track then name of a permission using, for example, array order (🤢)... this issue shown in the examples, where array order is used to get the name (`geoState`, and `notifState`):

```JS
    Promise.all([
      navigator.permissions.query({ name: "geolocation" }),
      navigator.permissions.query({ name: "notifications" })
    ])
    .then(([{ state: geoState }, { state: notifState }]) => {
      console.log("Geolocation permission state is:", geoState);
      console.log("Notifications permission state is:", notifState);
    });
```

The ideal design would be:

```JS
    const promises = ["geolocation", "notifications"].map(
      name => navigator.permissions.query( { name } )
    )
    const results = await Promise.all(promises);
    for (const { name, state } of results) {
      console.log("Permission ${name} state is ${state}");
    }
```


-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/permissions/issues/237

Received on Wednesday, 21 April 2021 06:04:06 UTC