Skip to content

Commit 50bf14f

Browse files
committed
fix(runtime-dom): 区分原生element元素calss 和style属性
1 parent 2d84df0 commit 50bf14f

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

packages/runtime-dom/src/index.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,15 @@ function setElementText(el, text) {
2323
el.textContent = text
2424
}
2525

26+
// 处理浏览器端 元素style样式
27+
function patchStyle(el, value) {
28+
console.log(value)
29+
const { style } = el
30+
for (const key in value) {
31+
style[key] = value[key]
32+
}
33+
}
34+
2635
function patchProp(el, key, preValue, nextValue) {
2736
// preValue 之前的值
2837
// 为了之后 update 做准备的值
@@ -52,6 +61,8 @@ function patchProp(el, key, preValue, nextValue) {
5261
invokers[key] = undefined
5362
}
5463
}
64+
} else if (key === 'style') {
65+
patchStyle(el, nextValue)
5566
} else {
5667
if (nextValue === null || nextValue === undefined) {
5768
el.removeAttribute(key)

0 commit comments

Comments
 (0)