Skip to content

Global component created before ref component when using bindTemplate #76

Open
@ThaNarie

Description

@ThaNarie

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?

Metadata

Metadata

Assignees

Labels

BugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions