Skip to content

Commit 43925db

Browse files
committed
fix: store style
1 parent 2e4916d commit 43925db

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

Diff for: packages/runtime-dom/src/modules/style.ts

+2-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { isString, hyphenate, capitalize, isArray } from '@vue/shared'
2-
import { camelize, isProxy } from '@vue/runtime-core'
2+
import { camelize } from '@vue/runtime-core'
33

44
type Style = string | Record<string, string | string[]> | null
55

@@ -8,12 +8,7 @@ export function patchStyle(el: Element, prev: Style, next: Style) {
88
const isCssString = isString(next)
99
if (next && !isCssString) {
1010
for (const key in next) {
11-
if (
12-
!isProxy(next) &&
13-
prev &&
14-
!isString(prev) &&
15-
prev[key] === next[key]
16-
) {
11+
if (prev && !isString(prev) && prev[key] === next[key]) {
1712
continue
1813
}
1914
setStyle(style, key, next[key])

Diff for: packages/shared/src/normalizeProp.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { isArray, isString, isObject, hyphenate } from './'
1+
import { isArray, isString, isObject, hyphenate, extend } from './'
22
import { isNoUnitNumericStyleProp } from './domAttrConfig'
33

44
export type NormalizedStyle = Record<string, string | number>
@@ -23,7 +23,10 @@ export function normalizeStyle(
2323
} else if (isString(value)) {
2424
return value
2525
} else if (isObject(value)) {
26-
return value
26+
// store normalized style under a different key for next diff
27+
// make sure to clone it if it's reactive, since the user likely wants
28+
// to mutate it.
29+
return extend({}, value)
2730
}
2831
}
2932

0 commit comments

Comments
 (0)