Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(runtime-core): mergeProps correctly #4156

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions packages/runtime-core/__tests__/vnode.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,12 @@ describe('vnode', () => {
expect(mergeProps(props1, props2, props3, props4)).toMatchObject({
class: 'c cc ccc cccc'
})

expect(
mergeProps({ class: { ccc: true } }, { disabled: true })
).toMatchObject({
class: 'ccc'
})
Comment on lines +355 to +357
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't that be:

Suggested change
).toMatchObject({
class: 'ccc'
})
).toMatchObject({
class: 'ccc',
disabled: true
})

})

test('style', () => {
Expand Down
2 changes: 2 additions & 0 deletions packages/runtime-core/src/vnode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,8 @@ export function normalizeChildren(vnode: VNode, children: unknown) {

export function mergeProps(...args: (Data & VNodeProps)[]) {
const ret = extend({}, args[0])
if (ret.class) ret.class = normalizeClass([ret.class])

for (let i = 1; i < args.length; i++) {
const toMerge = args[i]
for (const key in toMerge) {
Expand Down