Skip to content

Commit d5ade28

Browse files
committed
revert: feat: expose all scoped slots on this.$slots
This reverts commit 0129b0e.
1 parent 7bc88f3 commit d5ade28

File tree

2 files changed

+4
-30
lines changed

2 files changed

+4
-30
lines changed

src/core/vdom/helpers/normalize-scoped-slots.js

+3-11
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
/* @flow */
22

3-
import { hasOwn } from 'shared/util'
43
import { def } from 'core/util/lang'
54
import { normalizeChildren } from 'core/vdom/helpers/normalize-children'
65

@@ -17,7 +16,7 @@ export function normalizeScopedSlots (
1716
res = {}
1817
for (const key in slots) {
1918
if (slots[key] && key[0] !== '$') {
20-
res[key] = normalizeScopedSlot(normalSlots, key, slots[key])
19+
res[key] = normalizeScopedSlot(slots[key])
2120
}
2221
}
2322
}
@@ -32,20 +31,13 @@ export function normalizeScopedSlots (
3231
return res
3332
}
3433

35-
function normalizeScopedSlot(normalSlots, key, fn) {
36-
const normalized = (scope = {}) => {
34+
function normalizeScopedSlot(fn: Function): Function {
35+
return scope => {
3736
const res = fn(scope)
3837
return res && typeof res === 'object' && !Array.isArray(res)
3938
? [res] // single vnode
4039
: normalizeChildren(res)
4140
}
42-
// proxy scoped slots on normal $slots
43-
if (!hasOwn(normalSlots, key)) {
44-
Object.defineProperty(normalSlots, key, {
45-
get: normalized
46-
})
47-
}
48-
return normalized
4941
}
5042

5143
function proxyNormalSlot(slots, key) {

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

+1-19
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ describe('Component scoped slot', () => {
456456
})
457457

458458
// new in 2.6, unifying all slots as functions
459-
it('non-scoped slots should also be available on this.$scopedSlots', () => {
459+
it('non-scoped slots should also be available on $scopedSlots', () => {
460460
const vm = new Vue({
461461
template: `<foo>before <div slot="bar" slot-scope="scope">{{ scope.msg }}</div> after</foo>`,
462462
components: {
@@ -473,24 +473,6 @@ describe('Component scoped slot', () => {
473473
expect(vm.$el.innerHTML).toBe(`before after<div>hi</div>`)
474474
})
475475

476-
// #9421 the other side of unification is also needed
477-
// for library authors
478-
it('scoped slots should also be available on this.$slots', () => {
479-
const Child = {
480-
render: function (h) {
481-
return h(
482-
'div',
483-
this.$slots.content
484-
)
485-
}
486-
}
487-
const vm = new Vue({
488-
template: `<child><template #content>foo</template></child>`,
489-
components: { Child }
490-
}).$mount()
491-
expect(vm.$el.innerHTML).toBe(`foo`)
492-
})
493-
494476
// #4779
495477
it('should support dynamic slot target', done => {
496478
const Child = {

0 commit comments

Comments
 (0)