-
Notifications
You must be signed in to change notification settings - Fork 14
Open
Labels
new lint ruleNew lint rule requestNew lint rule request
Description
Global attributes are those that are present on all HTML elements. Some examples include
tabindexandrole. A custom element may wish to set its initialtabindexto0so it will be keyboard focusable. But you should always check first to see if the developer using your element has set this to another value. If, for example, they've settabindexto-1, it's a signal that they don't wish for the element to be interactive.
Ensure that there is a check for the attribute before altering (set/remove) the attribute in the connectedCallback.
if (!this.hasAttribute('foo')) this.setAttribute('foo', 'bar')
Resource:
https://developers.google.com/web/fundamentals/web-components/best-practices#do-not-override-author-set-global-attributes
https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes
Metadata
Metadata
Assignees
Labels
new lint ruleNew lint rule requestNew lint rule request