New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
defining and instantiating customized built‐in elements as if they were autonomous custom elements #613
Comments
This definitely feels like the darts are getting closer to the bullseye. With all the bright people looking at this there has to be a solution that satisfies what everyone loves about In other words, instead of introducing a |
Just want to point out a few more things that are indirectly relevant. In the V1 shadom dom spec we have a NOTICE section pointing out:
So why is it in the spec? Why are we all reading about something that we should never really use and that is useless? If we can come up with better solutions, then why did we not just do that in the first place? Also this HTML Imports document refers to using the |
I feel like #509 (comment) is easier to understand, and in that case your example following that pattern would be: let plasticButton = document.createElement("plastic-button");
console.log(plasticButton.localName); // will output "plastic-button"
console.log(plasticButton.getAttribute("is")); // will output "button" It would be great if this pattern would hold for all of customized built-in elements (custom classes that extend from built-in classes), built-in elements, and autonomous custom elements (custom classes that don't extend from built-in classes). It would also be super if |
I'm going to close this given that "There are plans to give every native HTML element their own class." never happened. That's a rather large-scale effort by itself that would have to be undertaken first and nobody has taken it up thus far even though it's been proposed for at least half a decade or so. If that happens one day perhaps some changes are possible along the lines of the proposal here, but I don't think we need to have a tracking issue for that. |
I think that a lot of people from #509 (at least @WebReflection, @trusktr, @oleersoy, the 14 people who upvoted the OP at the time of writing, and I) seem to agree that, even if it’s not ultimately bad, the
is
attribute doesn’t feel very natural, and isn’t very DRY. Even everyone who rejected the @trusktr’s original idea seemed to at least admit thatis
is not perfect.There, as a less drastic option, I proposed that customized built‐in elements should be instantiated like autonomous custom elements, and at least @WebReflection thought it was a good idea.
Here I’m proposing that customized built‐in elements should be defined and instantiated like autonomous custom elements.
There are plans to give every native HTML element their own class. Then, the fact that the class used to define the custom element extends a native element’s class should be enough information that the element should be a customized built‐in element, and not an autonomous custom element:
Additionally, the fact that the element has been defined as a customized built‐in element should be enough information that, when created, it should be a customized built‐in element:
Cons:
createElement
call thatplasticButton.localName
will be just"button"
. This issue would practically be inexistent in the real world, though, as development tools allow you to inspect the document tree, allowing you to clearly see the element’s tag name.The text was updated successfully, but these errors were encountered: