Open
Description
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
- Have a
- 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:
- Register the root as parent of global components, so the check works
- 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?