Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

<slot> will lost the first scoped style when the tags has a selector with v-if #10760

Closed
HuberTRoy opened this issue Oct 25, 2019 · 1 comment

Comments

@HuberTRoy
Copy link

Version

2.6.10

Reproduction link

https://codesandbox.io/s/vue-template-ptrum?fontsize=14

Steps to reproduce

When the parent style is scoped the <slot> will lost the style of the first tag if other tags on component has a selector with v-if.

Example:

Main.vue:

<template>
  <Test>
    <div class="test">
      <div class="test2">
      </div>
      <div class="test2">
      </div>
    </div>
  </Test>
</template>
<script>
import Test from './Test.vue'
export default {
     components: {
        Test
    }
}
</script>
<style scoped>
.test {
    display: flex;
}

.test2 {
   width: 200px;
   height: 200px;
   background: black;
}
</style>

Test.vue

<template>
  <div>
    <div v-if="f" class="_test_style_class_name">
    </div>
    <slot v-else>
    </slot>
  </div>
</template>
<script>
export default {
     data () {
         return {
             f: true
         }     
     },
     mounted () {  this.f = false }
}
</script>

Open it on Chrome, and no style set on class test but I have set it on Main.vue.
If I remove class="..." or remove v-if="f" on Test.vue then the class test will set..

Is it that I lost something to know in using <slot>?

Thanks.

What is expected?

No lost style.

What is actually happening?

No Style set on the first tag.

@Justineo
Copy link
Member

Duplicate of #10416

@Justineo Justineo marked this as a duplicate of #10416 Oct 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants