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

Injecting component-state-driven CSS variables in v-for loop at fragment root level #2177

Closed
davidbernegger opened this issue Sep 20, 2020 · 0 comments · Fixed by #2178
Closed

Comments

@davidbernegger
Copy link
Contributor

Version

3.0.0

Reproduction link

https://codesandbox.io/s/great-grothendieck-3zx5p?file=/src/App.vue

Steps to reproduce

When trying following code, the newly inserted nodes do not have the style attatched.

<template>
  <div
    v-for="(x, y, z) in object"
    :key="z"
    class="text"
    @click="addPropAndChangeColor"
  >
    {{ x }} 
  </div>
</template>

<script setup>
import { reactive, ref } from 'vue'
const object = reactive({
	firstProperty: 'This Has Color',
	SecondProperty: 'This Also Has color'
})

const color = ref('red')

const addPropAndChangeColor = function () {
	object[Math.random()] = 'Added Property does not have color'
	color.value = 'blue'
}

export {
	object,
	addPropAndChangeColor,
	color
}
</script>

<style vars="{ color }">
.text {
  color: var(--color);
}
</style>

if you wrap the v-for in a div so its not on the root the injection works.

<template>
<div>
  <div
    v-for="(x, y, z) in object"
    :key="z"
    class="text"
    @click="addPropAndChangeColor"
  >
    {{ x }} 
  </div>
</div>
</template>

What is expected?

Adding the styles to the node at the root should have styles

What is actually happening?

They do not have styles

underfin added a commit to underfin/vue-next that referenced this issue Sep 21, 2020
yyx990803 pushed a commit that referenced this issue Oct 13, 2020
…2178)

* fix(cssVars): should attach css vars while `subtree` changed

fix #2177

* fix: fix test
@github-actions github-actions bot locked and limited conversation to collaborators Nov 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant