Skip to content

Commit

Permalink
fix: v-bind object should not override props on scopedSlots (#5995)
Browse files Browse the repository at this point in the history
* v-bind object should not override props on scopedSlots

* Update render-slot.js
  • Loading branch information
javoski authored and yyx990803 committed Jun 30, 2017
1 parent 34d8c79 commit 458030a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/core/instance/render-helpers/render-slot.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export function renderSlot (
if (scopedSlotFn) { // scoped slot
props = props || {}
if (bindObject) {
extend(props, bindObject)
props = extend(extend({}, bindObject), props)
}
return scopedSlotFn(props) || fallback
} else {
Expand Down
10 changes: 5 additions & 5 deletions test/unit/features/component/component-scoped-slot.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe('Component scoped slot', () => {
template: `
<test ref="test">
<template scope="props">
<span>{{ props.msg }} {{ props.msg2 }}</span>
<span>{{ props.msg }} {{ props.msg2 }} {{ props.msg3 }}</span>
</template>
</test>
`,
Expand All @@ -45,23 +45,23 @@ describe('Component scoped slot', () => {
data () {
return {
msg: 'hello',
obj: { msg2: 'world' }
obj: { msg2: 'world', msg3: '.' }
}
},
template: `
<div>
<slot :msg="msg" v-bind="obj"></slot>
<slot :msg="msg" v-bind="obj" msg3="!"></slot>
</div>
`
}
}
}).$mount()

expect(vm.$el.innerHTML).toBe('<span>hello world</span>')
expect(vm.$el.innerHTML).toBe('<span>hello world !</span>')
vm.$refs.test.msg = 'bye'
vm.$refs.test.obj.msg2 = 'bye'
waitForUpdate(() => {
expect(vm.$el.innerHTML).toBe('<span>bye bye</span>')
expect(vm.$el.innerHTML).toBe('<span>bye bye !</span>')
}).then(done)
})

Expand Down

0 comments on commit 458030a

Please sign in to comment.