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

Global component created before ref component when using bindTemplate #76

Open
ThaNarie opened this issue Mar 11, 2022 · 0 comments
Open
Assignees
Labels
Bug Something isn't working

Comments

@ThaNarie
Copy link
Contributor

Use case:

  • register a component globally (e.g. an icon)
  • In an existing component
    • Have a refComponent that is not in your main template
    • That has a child refComponent that is an icon
    • using bindTemplate, render some HTML that contains the child component and within it a template
  • observe that the icon component is first registered globally (right after the bindTemplate)
  • and after that, the child and icon components are inited
  • causing an error in the console with This refComponent does already exist as part of another parent

The existing check if (existingComponent.__instance.parent?.uid === 0) doesn't work, since the first component is registered as its parent, and not the root.

Two options:

  1. Register the root as parent of global components, so the check works
  2. Keep the current "parent" in there, but find another way to detect globally registered components

Not sure if it's useful to know which parent "owned" the piece of HTML that resulted in the globally registered component.

Additionally, it would be good to investigate the component initialisation of bindTemplate vs global components, maybe the order could be turned around?

@ThaNarie ThaNarie self-assigned this Mar 11, 2022
@ThaNarie ThaNarie added the Bug Something isn't working label Mar 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant