Skip to content

parent data-... tag omitted for child components with falsy v-if on root elements #576

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

Closed
7sempra opened this issue Jan 15, 2017 · 2 comments

Comments

@7sempra
Copy link

7sempra commented Jan 15, 2017

Consider this child component:

<template>
<div v-if="showMe" class="child-root"></div>
</template>

And this parent component:

<template>
<div>
  <my-child class="make-it-red" />
</div>
</template>

<style scoped>
.make-it-red {
  background-color: red;
}
</style>

Assume the scope tags for these two components are data-v-0000000a and data-v-0000000b.

Normally, the child-root element should have BOTH scope tags. However, if showMe starts out false, then child-root is never given the parent scope tag (data-v-0000000a). It only gets data-v-0000000b, which means that make-it-red never applies to child-root.

Correct output (after showMe has been flipped to true):

<div data-v-0000000a>
  <div data-v-0000000a data-v-0000000b class="child-root make-it-red"></div>
</div>

Actual output:

<div data-v-0000000a>
  <div data-v-0000000b class="child-root make-it-red"></div>
</div>
@kazupon kazupon added the bug label Jan 15, 2017
@Akryum
Copy link
Member

Akryum commented Jan 18, 2017

I got the same issue with the following use case:

<tabs>
  <tab>...</tab>
  <tab>...</tab>
</tabs>
<template>
  <div class="tab" v-if="isCurrentTab"><slot/></div>
</template>

I couldn't apply style to the <tab> elements in the scoped style.

@kazupon
Copy link
Member

kazupon commented Jan 23, 2017

Close (fixed vuejs/vue#4774)

@kazupon kazupon closed this as completed Jan 23, 2017
@kazupon kazupon removed the bug label Jan 23, 2017
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

3 participants