Skip to content

Commit

Permalink
Revert "fix(runtime-dom): Fixed a runtime error when the element node…
Browse files Browse the repository at this point in the history
…'s style binding array was not compiled as 'createStaticVNode'. (fix vuejs#5106)"
  • Loading branch information
baiwusanyu-c committed May 10, 2022
1 parent 6a346ca commit cd4b15c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 15 deletions.
7 changes: 1 addition & 6 deletions packages/runtime-dom/__tests__/patchStyle.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,7 @@ describe(`runtime-dom: style patching`, () => {
patchProp(el, 'style', {}, 'color:red')
expect(el.style.cssText.replace(/\s/g, '')).toBe('color:red;')
})
// #5106
it('Array', () => {
const el = document.createElement('div')
patchProp(el, 'style', {}, [{color:'red'}])
expect(el.style.cssText.replace(/\s/g, '')).toBe('color:red;')
})

// #1309
it('should not patch same string style', () => {
const el = document.createElement('div')
Expand Down
11 changes: 2 additions & 9 deletions packages/runtime-dom/src/modules/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,8 @@ export function patchStyle(el: Element, prev: Style, next: Style) {
const style = (el as HTMLElement).style
const isCssString = isString(next)
if (next && !isCssString) {
// #5106
if(Array.isArray(next)){
next.forEach(val=>{
patchStyle(el,prev,val)
})
}else{
for (const key in next) {
setStyle(style, key, next[key])
}
for (const key in next) {
setStyle(style, key, next[key])
}
if (prev && !isString(prev)) {
for (const key in prev) {
Expand Down

0 comments on commit cd4b15c

Please sign in to comment.