File tree 2 files changed +31
-5
lines changed
test/unit/features/component
2 files changed +31
-5
lines changed Original file line number Diff line number Diff line change @@ -627,6 +627,13 @@ function processSlotContent (el) {
627
627
el
628
628
)
629
629
}
630
+ if ( el . scopedSlots ) {
631
+ warn (
632
+ `To avoid scope ambiguity, the default slot should also use ` +
633
+ `<template> syntax when there are other named slots.` ,
634
+ slotBinding
635
+ )
636
+ }
630
637
}
631
638
// add the component's children to its default slot
632
639
const slots = el . scopedSlots || ( el . scopedSlots = { } )
Original file line number Diff line number Diff line change @@ -686,11 +686,13 @@ describe('Component scoped slot', () => {
686
686
expect ( vm . $el . innerHTML . trim ( ) ) . toBe ( `from foo default | from bar | from baz` )
687
687
} )
688
688
689
- it ( 'default + named slots' , ( ) => {
689
+ it ( 'named slots' , ( ) => {
690
690
const vm = new Vue ( {
691
691
template : `
692
- <foo #default="foo">
693
- {{ foo }}
692
+ <foo>
693
+ <template ${ toNamed ( syntax , 'default' ) } ="foo">
694
+ {{ foo }}
695
+ </template>
694
696
<template ${ toNamed ( syntax , 'one' ) } ="one">
695
697
{{ one }}
696
698
</template>
@@ -748,8 +750,10 @@ describe('Component scoped slot', () => {
748
750
it ( 'shorthand named slots' , ( ) => {
749
751
const vm = new Vue ( {
750
752
template : `
751
- <foo #default="foo">
752
- {{ foo }}
753
+ <foo>
754
+ <template #default="foo">
755
+ {{ foo }}
756
+ </template>
753
757
<template #one="one">
754
758
{{ one }}
755
759
</template>
@@ -763,6 +767,21 @@ describe('Component scoped slot', () => {
763
767
expect ( vm . $el . innerHTML . replace ( / \s + / g, ' ' ) ) . toMatch ( `from foo default from foo one from foo two` )
764
768
} )
765
769
770
+ it ( 'should warn mixed root-default and named slots' , ( ) => {
771
+ const vm = new Vue ( {
772
+ template : `
773
+ <foo #default="foo">
774
+ {{ foo }}
775
+ <template #one="one">
776
+ {{ one }}
777
+ </template>
778
+ </foo>
779
+ ` ,
780
+ components : { Foo }
781
+ } ) . $mount ( )
782
+ expect ( `default slot should also use <template>` ) . toHaveBeenWarned ( )
783
+ } )
784
+
766
785
it ( 'shorthand without scope variable' , ( ) => {
767
786
const vm = new Vue ( {
768
787
template : `
You can’t perform that action at this time.
0 commit comments