question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

The new child element contains the parent.

See original GitHub issue

REPL

I have one component that should conditionally wrap another component (one it’s an app, the other is something like a mockup for better visuals).

I was initializing them like:

	const appContainer = document.createElement('DIV')
    new App({ target: appContainer })
    new POS({
      target: root,
      slots: {
        default: appContainer,
      },
    })

And started receiving the error: Failed to execute 'appendChild' on 'Node': The new child element contains the parent.

However, if you replace the createElement with a createDocumentFragment it works 100%.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
kaisermanncommented, Jul 24, 2018

@ekhaled I see! Thank you so much for your insights 😁

1reaction
ekhaledcommented, Jul 24, 2018

Programmatic slots are not a public api. Svelte uses either appendNode or insertNode depending on whether it has to render slot content conditionally.

In OP’s case… if you set the condition to be true to start with (in Machine.html’s data), you will notice that it works perfectly.

Fortunately, using a fragment works for both insertNode and appendNode

Read more comments on GitHub >

github_iconTop Results From Across the Web

The new child element contains the parent - Stack Overflow
Part of the problem is that you are assigning both the <td> and the <img> the exact same id. You can't do that....
Read more >
How to return true if the parent element ... - Tutorialspoint
In this tutorial, we are going to look at how we can return true if the parent element contains the child element in...
Read more >
JavaScript: Return true if the parent element contains the child ...
Use Node.contains() to check if the parent element contains the child element. Sample Solution: JavaScript Code: //#Source https://bit.
Read more >
Node.appendChild() - Web APIs - MDN Web Docs
Node.appendChild() ... The appendChild() method of the Node interface adds a node to the end of the list of children of a specified...
Read more >
How to return true if the parent element ... - GeeksforGeeks
In order to check whether the parent element (say x) contains a child element (say y), we can use the children property to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found