howto-components icon indicating copy to clipboard operation
howto-components copied to clipboard

Docs should explain why you're not extending built-in elements.

Open markcaron opened this issue 8 years ago • 4 comments

As Eric Bidelman noted, "There's no better way to write a progressive web app than to progressively enhance existing HTML elements." [1]

Where possible, buttons and other custom elements should extend native HTML elements "to gain all of its features (DOM properties, methods, accessibility)". [1]

[1] https://developers.google.com/web/fundamentals/web-components/customelements#extendhtml

markcaron avatar Oct 03 '17 14:10 markcaron

Agreed, where possible, native elements should be used. See 7ca365291863f310c5006a01ec3029c62a485a6b

surma avatar Oct 03 '17 14:10 surma

Unfortunately there's a lot of contention around extending built-in elements with some browsers stating that they will "never" support it. Even libraries like Polymer are dropping support (in the near term) to see if we can find consensus on a different solution. For these reasons we've chosen to not do customized built-ins on this project and we're going to be updating the docs wherever possible to indicate when using a native element would be preferable. This is a good issue because it reminds me we should add a similar warning to the toggle button.

robdodson avatar Oct 05 '17 03:10 robdodson

Awesome! Thanks, Rob and Surma. I figured you had a good reason for not extending HTMLButtonElement. :-)

A warning would be helpful. Thanks for the explanation.

markcaron avatar Oct 05 '17 13:10 markcaron

I changed the title of this issue and I'm reopening so we can go back and add this explanation to the docs.

robdodson avatar Oct 08 '17 19:10 robdodson