computed style inside list is not applied
Vue version
3.2
Link to minimal reproduction
Steps to reproduce
<script setup>
import { computed } from 'vue';
const red = computed(() => ({color: 'red'}));
const list = [red];
</script>
<template>
<div :style="red">{{red}} Should be red</div>
<div v-for="(g, idx) in list" :key="idx" :style="g">{{g}} Should also be red</div>
</template>
What is expected?
Both lines should be in red color
What is actually happening?
Only the top row is red
System Info
System:
OS: Windows 10 10.0.19044
CPU: (8) x64 Intel(R) Core(TM) i5-8250U CPU @ 1.60GHz
Memory: 6.07 GB / 15.86 GB
Binaries:
Node: 14.19.0 - C:\Program Files\nodejs\node.EXE
npm: 6.14.16 - C:\Program Files\nodejs\npm.CMD
Browsers:
Chrome: 104.0.5112.101
Edge: Spartan (44.19041.1266.0), Chromium (104.0.1293.63)
Internet Explorer: 11.0.19041.1566
Any additional comments?
I tried to debug myself and it seems like patchStyle
is enumerating over the proxy's keys, not the keys in the target. I'm not sure why.
Thus, a workaround is to use :style="g.value"
on the computed style instead of :style="g"
.