-2

In the new era of web components MDN (and probably the standard) suggests extending the HTMLElement class.

For a long time we've strayed away from doing that, what has changed now for this to become the suggested standard?

Is it a particularly good idea in the long-term, what happens if in the future the standard gets extended and implements currently non-existent methods which you happen to define in your extending classes?

6
  • I don't see where MDN suggests extending HTMLElement in your reference. Can you point out a quote? MDN does say "Some elements directly implement this interface, while others implement an interface that inherits from it." That is not a suggestion. It is a statement of what the DOM currently does. So is your question about the evolution of the standard? Or is it about what we should or should not do in our applications that use the DOM? – joshp Oct 3 '20 at 17:14
  • @joshp it may not be written in plain text but how else are you going to register a custom element if it doesn't implement the Element interface? I'm mostly concerned about what will happen to apps when the standard extends and overwrites properties/functions that are already in use by their custom elements. – php_nub_qq Oct 3 '20 at 18:03
  • @joshp - click the first link; I'd say that the fact there's a whole article on creating custom elements is inherently suggestive to people (as in: it suggest that this may be a technology worth considering). @ OP: I think the answer boils down to (1) the emergence Web Components-related standards, and (2) browser support (see this, this. As for whether it's a particularly good idea - not sure. – Filip Milovanović Oct 3 '20 at 18:18
  • 1
    @php_nub_qq You should spell that out in your question. Do you just want people to criticize or support the current evolution of the standard? (probably opinion based) or do you want to ask about practical ways to build custom components that can withstand future additions to HTMLElement? Or is it "What happens if the standard HTMLElement interface. adds a method that conflicts with a custom component method?" Just asking "Is X a good idea?" usually doesn't get you a good answer here. I think there's a good question or two here if you want to clarify. – joshp Oct 3 '20 at 18:47
  • 1
    @FilipMilovanović I did. I think there are some great questions here. But there's work required to make it clear which one we're focusing on and why. My aim is simply to help OP avoid having his question closed, and get us one or more good questions. – joshp Oct 3 '20 at 18:49
-2

yes, it's a very good idea if the HtmlElement is extended and modified in a long-term form, such as a class that is made efficient and attractive, it will make web performance in html form better and more developed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.