Closed tronicboy1 closed 1 year ago
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).
View this failed invocation of the CLA check for more information.
For the most up to date status, view the checks section at the bottom of the pull request.
Even though this is a small code change, it is a major behavior change that would require an RFC. @customElement()
is only a declarative shorthand for customElements.define()
- it's been important that the behavior matches. We also don't put features in decorators that are not available in plain JS.
Given a single global registry, and no way to tell if two registrations for the same name are compatible, throwing is the more correct and conservative thing to do. We may wish to explore some other option, but that would involve some way of element definition describing what other definitions they are compatible with and still throwing if they aren't known to be compatible.
@justinfagnani I totally understand where your coming from with that. You could have multiple packages trying to define the same name and have no way to see that as an error.
I'll close this PR, sorry for wasting your time!
@tronicboy1 not a waste. I think we should do something here for use cases that need it, it's just a little complicated. Hopefully scoped element registries solve most cases.
@justinfagnani First time hearing about scoped registries. Your proposal makes a lot of sense and I for one would be very happy to see it realized!
thanks again for all of your work.
Reference Issue
Fixes #3794
Change
customElement
decorator to not define a custom element if it is already in the registry.This eliminates DOM exceptions when multiple scripts are accidentally imported.