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.

Duplicate "container element"s

See original GitHub issue

Version

3.2.30

Reproduction link

stackblitz.com

Steps to reproduce

In Vue 2 when we wrap things in #app we don’t get 2 container elements. In Vue 3 though, we do.

Check Vue 2 project: https://codesandbox.io/s/reverent-tdd-4hs4j?file=/src/App.vue Check Vue 3 project: https://stackblitz.com/edit/vitejs-vite-jnq5k4?file=src/App.vue

Vue 2 screenshot:

image

Vue 3 screenshot:

image

Notice the 2 container elements with id app in Vue 3 version

What is expected?

Vue 2 and Vue 3 should both render one container element

What is actually happening?

In Vue 3 2 nested container elements are rendered


I know that in Vue 3 we can have multiple root elements, but I think the container elements functionality should be the same in Vue 3.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
LinusBorgcommented, Feb 18, 2022

You can try mounting to body, if that helps. But likely not a good idea as it will replace the content

I can accept that you can’t understand it but that’s what it is.

1reaction
LinusBorgcommented, Feb 9, 2022

The reason is “Fragments”, pretty much. As we can’t guarantee a single root node, replacing the element at mount with several others, whose number also could change over time, could have unintended side-effects in cases where the document in which the app is mounted is controlled by other code, or break styling etc.

The RFC can be found here https://github.com/vuejs/rfcs/blob/master/active-rfcs/0009-global-api-change.md#mounting-behavior-difference-from-2x

Docs: https://vuejs.org/api/application.html#app-mount

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to copy/clone div to corresponding structure in other ...
I try to copy all "copy-this" elements to the same location in the other container. So first ".copy-this" should be duplicated in the...
Read more >
aj on Twitter: "@sixhobbits You can duplicate a whole ...
2. is there a way that I'm missing to duplicate an element or container? Seems like it would be really useful to be...
Read more >
How to copy or clone an element with vanilla JS
Copying an element # ... First, let's use the querySelector() method to get our #elem1 element. // Get the element var elem =...
Read more >
Algorithms to copy, move and remove container elements
Within this article I want to give an overview about the STL algorithms to copy, move and remove container elements.
Read more >
Duplicating into other pages - General - Forum | Webflow
I am trying to duplicate one container into different pages so that I don't have to replicate the same work inside a container...
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