File tree Expand file tree Collapse file tree 2 files changed +14
-26
lines changed
test/unit/features/component Expand file tree Collapse file tree 2 files changed +14
-26
lines changed Original file line number Diff line number Diff line change @@ -169,9 +169,10 @@ export function parse (
169
169
if ( currentParent && ! element . forbidden ) {
170
170
if ( element . else ) { // else block
171
171
processElse ( element , currentParent )
172
- } else if ( element . slotTarget && element . slotScope ) { // scoped slot
173
- ( currentParent . scopedSlots || ( currentParent . scopedSlots = { } ) ) [ element . slotTarget ] = element
172
+ } else if ( element . slotScope ) { // scoped slot
174
173
currentParent . plain = false
174
+ const name = element . slotTarget || 'default'
175
+ ; ( currentParent . scopedSlots || ( currentParent . scopedSlots = { } ) ) [ name ] = element
175
176
} else {
176
177
currentParent . children . push ( element )
177
178
element . parent = currentParent
@@ -356,6 +357,8 @@ function processSlot (el) {
356
357
const slotTarget = getBindingAttr ( el , 'slot' )
357
358
if ( slotTarget ) {
358
359
el . slotTarget = slotTarget === '""' ? '"default"' : slotTarget
360
+ }
361
+ if ( el . tag === 'template' ) {
359
362
el . slotScope = getAndRemoveAttr ( el , 'scope' )
360
363
}
361
364
}
Original file line number Diff line number Diff line change 1
1
import Vue from 'vue'
2
2
3
- describe ( 'Component scoped slot' , ( ) => {
4
- it ( 'default slot' , ( ) => {
5
- const vm = new Vue ( {
6
- template : `<test><span slot scope="props">{{ props.msg }}</span></test>` ,
7
- components : {
8
- test : {
9
- data ( ) {
10
- return { msg : 'hello' }
11
- } ,
12
- template : `
13
- <div>
14
- <slot :msg="msg"></slot>
15
- </div>
16
- `
17
- }
18
- }
19
- } ) . $mount ( )
20
- expect ( vm . $el . innerHTML ) . toBe ( '<span>hello</span>' )
21
- } )
22
-
23
- it ( 'normal element slot' , done => {
3
+ fdescribe ( 'Component scoped slot' , ( ) => {
4
+ it ( 'default slot' , done => {
24
5
const vm = new Vue ( {
25
6
template : `
26
7
<test ref="test">
27
- <span slot="item" scope="props">{{ props.text }}</span>
8
+ <template scope="props">
9
+ <span>{{ props.msg }}</span>
10
+ </template>
28
11
</test>
29
12
` ,
30
13
components : {
@@ -34,7 +17,7 @@ describe('Component scoped slot', () => {
34
17
} ,
35
18
template : `
36
19
<div>
37
- <slot name="item" :text ="msg"></slot>
20
+ <slot :msg ="msg"></slot>
38
21
</div>
39
22
`
40
23
}
@@ -204,7 +187,9 @@ describe('Component scoped slot', () => {
204
187
const vm = new Vue ( {
205
188
template : `
206
189
<test ref="test">
207
- <span slot="item" scope="props">{{ props.text || 'meh' }}</span>
190
+ <template slot="item" scope="props">
191
+ <span>{{ props.text || 'meh' }}</span>
192
+ </template>
208
193
</test>
209
194
` ,
210
195
components : {
You can’t perform that action at this time.
0 commit comments