An origin trial for a new HTML <permission> element
a year ago
- #Web Development
- #Chrome
- #Permissions
- Chrome introduces a new declarative HTML <permission> element for requesting permissions in web apps.
- Current imperative methods for requesting permissions (e.g., Geolocation API, Notification API) have challenges like permission spam and lack of contextualization.
- The <permission> element is in origin trial from Chrome 126, aiming to standardize permission requests.
- Key attributes of the <permission> element include 'type' for specifying permissions and 'type-ext' for additional parameters.
- The element automatically updates its text based on the permission status (granted, denied, etc.).
- Styling restrictions are applied to the <permission> element to ensure recognizability and usability.
- JavaScript events like 'onpromptdismiss' and 'onpromptaction' allow developers to handle user interactions with the permission prompt.
- Feature detection can be done using 'HTMLPermissionElement' in window.
- The <permission> element is discussed with other browser vendors for potential standardization.
- A demo and source code are available on GitHub for developers to explore.