Skip to content

Commit 458030a

Browse files
javoskiyyx990803
authored andcommitted
fix: v-bind object should not override props on scopedSlots (#5995)
* v-bind object should not override props on scopedSlots * Update render-slot.js
1 parent 34d8c79 commit 458030a

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/core/instance/render-helpers/render-slot.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export function renderSlot (
1515
if (scopedSlotFn) { // scoped slot
1616
props = props || {}
1717
if (bindObject) {
18-
extend(props, bindObject)
18+
props = extend(extend({}, bindObject), props)
1919
}
2020
return scopedSlotFn(props) || fallback
2121
} else {

test/unit/features/component/component-scoped-slot.spec.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ describe('Component scoped slot', () => {
3636
template: `
3737
<test ref="test">
3838
<template scope="props">
39-
<span>{{ props.msg }} {{ props.msg2 }}</span>
39+
<span>{{ props.msg }} {{ props.msg2 }} {{ props.msg3 }}</span>
4040
</template>
4141
</test>
4242
`,
@@ -45,23 +45,23 @@ describe('Component scoped slot', () => {
4545
data () {
4646
return {
4747
msg: 'hello',
48-
obj: { msg2: 'world' }
48+
obj: { msg2: 'world', msg3: '.' }
4949
}
5050
},
5151
template: `
5252
<div>
53-
<slot :msg="msg" v-bind="obj"></slot>
53+
<slot :msg="msg" v-bind="obj" msg3="!"></slot>
5454
</div>
5555
`
5656
}
5757
}
5858
}).$mount()
5959

60-
expect(vm.$el.innerHTML).toBe('<span>hello world</span>')
60+
expect(vm.$el.innerHTML).toBe('<span>hello world !</span>')
6161
vm.$refs.test.msg = 'bye'
6262
vm.$refs.test.obj.msg2 = 'bye'
6363
waitForUpdate(() => {
64-
expect(vm.$el.innerHTML).toBe('<span>bye bye</span>')
64+
expect(vm.$el.innerHTML).toBe('<span>bye bye !</span>')
6565
}).then(done)
6666
})
6767

0 commit comments

Comments
 (0)