From cd4b15c4d4373de8f349eaa330eb9f59a505f787 Mon Sep 17 00:00:00 2001 From: czh740132583 <740132583@qq.com> Date: Tue, 10 May 2022 22:36:38 +0800 Subject: [PATCH] Revert "fix(runtime-dom): Fixed a runtime error when the element node's style binding array was not compiled as 'createStaticVNode'. (fix #5106)" --- packages/runtime-dom/__tests__/patchStyle.spec.ts | 7 +------ packages/runtime-dom/src/modules/style.ts | 11 ++--------- 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/packages/runtime-dom/__tests__/patchStyle.spec.ts b/packages/runtime-dom/__tests__/patchStyle.spec.ts index f84a176087f..409d6936eaf 100644 --- a/packages/runtime-dom/__tests__/patchStyle.spec.ts +++ b/packages/runtime-dom/__tests__/patchStyle.spec.ts @@ -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') diff --git a/packages/runtime-dom/src/modules/style.ts b/packages/runtime-dom/src/modules/style.ts index f53d6e0e171..f4924ea2ec6 100644 --- a/packages/runtime-dom/src/modules/style.ts +++ b/packages/runtime-dom/src/modules/style.ts @@ -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) {