Skip to content

Scoped styles applied to child component when component has 1 root element or when used composition api #3382

Closed
@mixalbl4-127

Description

@mixalbl4-127

Version

3.0.7

Reproduction link

https://codesandbox.io/s/nice-bas-xpf2b?file=/src/components/HelloWorld.vue

Steps to reproduce

Open: https://codesandbox.io/s/nice-bas-xpf2b?file=/src/components/HelloWorld.vue

see that the same logic works different depended on compostion api or count of root element.

What is expected?

<style scoped>
.tst {
  background: red;
}
</style>

background: red; must never be applied to child component class

What is actually happening?

class .tst applied to child components when:

  1. Child root component is only one
  2. Child root component is switched by v-if
  3. Child root component used composition API for adding second, third etc elements to DOM (in this case only FIRST element got background: red;)

scoped styles must never be applied to child compontens OR at least always (no matter it used composition api or have 2-3-5 root childs), we need clear login like "always works like this" or "newer works like this"

When used Composition api for SWITH (like v-if) - first DOM element will have background: red; but second - no. Its extra strange because I have only 1 root element in one time (like v-if) but second elemen doest get style.

Metadata

Metadata

Assignees

No one assigned

    Labels

    🔨 p3-minor-bugPriority 3: this fixes a bug, but is an edge case that only affects very specific usage.🐞 bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions