Custom Elements can extend from any available element, for example HTMLParagraphElement.
There are a few reasons for why you would want to only extend from HTMLElement.
- As new features get added to HTML elements, custom elements that extend those built-in elements need to adopt those new features which can cause complications especially with regards to cross-browser support.
- Safari doesn't support and doesn't plan on supporting extending from other elements than HTMLElement.
This rule restricts Custom Elements to only extend from HTMLElement.
👎 Examples of incorrect code for this rule:
class MyListElement extends HTMLUListElement {
// ...
}
👍 Examples of correct code for this rule:
class MyListElement extends HTMLElement {
// ...
}
If you want to extend from built-in elements, don't need to support Safari (or are happy using a polyfill) and are OK with the trade-offs, then this rule can be disabled.