Skip to content

Commit

Permalink
fix(runtime-core): fix v-bind class/style merging regression
Browse files Browse the repository at this point in the history
fix #4155
  • Loading branch information
yyx990803 committed Jul 20, 2021
1 parent acb2a4d commit 2bdee50
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
12 changes: 7 additions & 5 deletions packages/runtime-core/__tests__/vnode.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ describe('vnode', () => {

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

test('style', () => {
let props1: Data = {
style: {
color: 'red',
fontSize: 10
}
style: [
{
color: 'red',
fontSize: 10
}
]
}
let props2: Data = {
style: [
Expand Down
4 changes: 2 additions & 2 deletions packages/runtime-core/src/vnode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -778,8 +778,8 @@ export function normalizeChildren(vnode: VNode, children: unknown) {
}

export function mergeProps(...args: (Data & VNodeProps)[]) {
const ret = extend({}, args[0])
for (let i = 1; i < args.length; i++) {
const ret: Data = {}
for (let i = 0; i < args.length; i++) {
const toMerge = args[i]
for (const key in toMerge) {
if (key === 'class') {
Expand Down

0 comments on commit 2bdee50

Please sign in to comment.