Skip to content

Style-vars-2 v-bind feature issue when using transition and v-if #3894

@Sackeys

Description

@Sackeys

Version

3.1.0-beta.7

Reproduction link

https://codesandbox.io/s/vue3-style-vars-2-issue-v-if-style-vars-binding-inside-transition-4qtf1

Steps to reproduce

Create the following component:

<template>
  <transition>
    <div v-if="isDisplayed" class="bloc"></div>
  </transition>
</template>

<script>
import { ref } from "vue"

export default {
  setup() {
    const isDisplayed = ref(false)
    const color = "#8BA7AF"

    setTimeout(() => isDisplayed.value = true, 1000)

    return {
      isDisplayed,
      color
    }
  }
}
</script>

<style scoped>
.bloc {
  width: 100px;
  height: 100px;
  background-color: v-bind(color);
}
</style>

The transition content will be displayed one second after the component was created.

What is expected?

The HTML node (transition child) should contain the style variables.

What is actually happening?

The HTML node (transition child) doesn't contain the style variables so the component is not well displayed.

sample


It doesn't work either with OptionAPI, neither with CompositionAPI.
DOM inspection:

<div id="app" data-v-app="">
    <div class="bloc" data-v-149ffcac="" style="--149ffcac-color:#9F8BAF;"> [OptionAPI] not deferred</div>
    <div class="bloc" data-v-885362c0="" style="--885362c0-color:#8BA7AF;"> [CompositionAPI] not deferred</div>
    <div class="bloc" data-v-149ffcac=""> [OptionAPI] deferred</div>
    <div class="bloc" data-v-885362c0=""> [CompositionAPI] deferred</div>
</div>

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions