Skip to content
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

[Feat]: Provide devmode help on custom element registration conflicts #2666

Closed
1 task done
hunterloftis opened this issue Oct 18, 2022 · 1 comment
Closed
1 task done
Labels

Comments

@hunterloftis
Copy link
Contributor

hunterloftis commented Oct 18, 2022

Code of conduct

  • I agree to follow this project's code of conduct.

Impacted component(s)

all

Description of the requested feature

Before we call customElementRegistry.define, which can potentially trigger an exception like:

Uncaught DOMException: Failed to execute 'define' on 'CustomElementRegistry': the name "sp-icon-alert" has already been used with this registry

We should check to see if a given element is already defined. If so, we should output help text that includes:

  1. An explanation of what's happening (one global registry, two versions of the same tag trying to register)
  2. A suggestion why (usually, multiple versions installed via transitive dependencies in package.json)
  3. A link to a documentation URL that walks users through resolving the issue in common cases (yarn why etc).

Mockups or screenshots

No response

Implementation notes or ideas

customElementRegistry.get('sp-foo')

If we're able to retrieve package versions, we could provide even more helpful output ("Trying to register sp-foo 1.2.3 but sp-foo 1.1.1 is already registered"). This would make spotting the issue in tools like yarn why easier.

@Westbrook
Copy link
Contributor

fixed in #3171

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants