43081j / 43081j/eslint-plugin-wc
Do not override author-set, global attributes
- 主要語言
- TypeScript
- 星號
- 113
- 分支
- 19
- 平均合併
- 3 小時 14 分鐘
- 30 天內合併 PR
- 2
描述
> Global attributes are those that are present on all HTML elements. Some examples include `tabindex` and `role`. A custom element may wish to set its initial `tabindex` to `0` so 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 set `tabindex` to `-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
貢獻指南
這個儲存庫沒有索引到貢獻指南
評估
這個 Issue 還沒有評估資料。