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

fix(runtime-dom): clear prev style with string and object #10313

Closed
wants to merge 1 commit into from

Conversation

FireBushtree
Copy link

  1. use this code, after click button, the text style will change to 'font-size: 12px'
<script setup>
import { ref } from 'vue'

const style = ref({ color: 'red' })
function handleClick() {
  style.value = { fontSize: '12px' }
}
</script>

<template>
  <h1 :style="style">Hello World</h1>
  <button @click="handleClick">change style</button>
</template>
  1. but this code, after click button, the text style will change to 'color: red; font-size: 12px'. the 'color: red' do not be removed
<script setup>
import { ref } from 'vue'

const style = ref('color: red')
function handleClick() {
  style.value = { fontSize: '12px' }
}
</script>

<template>
  <h1 :style="style">Hello World</h1>
  <button @click="handleClick">change style</button>
</template>

@yyx990803
Copy link
Member

Thanks for the PR - however I think #10373 is a cleaner fix as it avoids allocating a temporary object (we only need the keys).

@yyx990803 yyx990803 closed this Feb 25, 2024
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

Successfully merging this pull request may close these issues.

2 participants