fix(runtime-core): fix v-bind class/style merging regression

fix #4155
This commit is contained in:
Evan You 2021-07-20 13:58:43 -04:00
parent acb2a4d285
commit 2bdee50a59
2 changed files with 9 additions and 7 deletions

View File

@ -342,7 +342,7 @@ describe('vnode', () => {
describe('mergeProps', () => { describe('mergeProps', () => {
test('class', () => { test('class', () => {
let props1: Data = { class: 'c' } let props1: Data = { class: { c: true } }
let props2: Data = { class: ['cc'] } let props2: Data = { class: ['cc'] }
let props3: Data = { class: [{ ccc: true }] } let props3: Data = { class: [{ ccc: true }] }
let props4: Data = { class: { cccc: true } } let props4: Data = { class: { cccc: true } }
@ -353,10 +353,12 @@ describe('vnode', () => {
test('style', () => { test('style', () => {
let props1: Data = { let props1: Data = {
style: { style: [
{
color: 'red', color: 'red',
fontSize: 10 fontSize: 10
} }
]
} }
let props2: Data = { let props2: Data = {
style: [ style: [

View File

@ -778,8 +778,8 @@ export function normalizeChildren(vnode: VNode, children: unknown) {
} }
export function mergeProps(...args: (Data & VNodeProps)[]) { export function mergeProps(...args: (Data & VNodeProps)[]) {
const ret = extend({}, args[0]) const ret: Data = {}
for (let i = 1; i < args.length; i++) { for (let i = 0; i < args.length; i++) {
const toMerge = args[i] const toMerge = args[i]
for (const key in toMerge) { for (const key in toMerge) {
if (key === 'class') { if (key === 'class') {