File tree 2 files changed +17
-5
lines changed
test/unit/specs/directives/element 2 files changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -35,11 +35,12 @@ export default {
35
35
// Default content
36
36
var self = this
37
37
var compileDefaultContent = function ( ) {
38
- self . compile (
39
- extractFragment ( raw . childNodes , raw , true ) ,
40
- context ,
41
- host
42
- )
38
+ var content = extractFragment ( raw . childNodes , raw , true )
39
+ if ( content . hasChildNodes ( ) ) {
40
+ self . compile ( content , context , host )
41
+ } else {
42
+ self . fallback ( )
43
+ }
43
44
}
44
45
if ( ! host . _isCompiled ) {
45
46
// defer until the end of instance compilation,
Original file line number Diff line number Diff line change @@ -59,6 +59,17 @@ describe('Slot Distribution', function () {
59
59
expect ( el . lastChild . textContent ) . toBe ( 'slot b' )
60
60
} )
61
61
62
+ it ( 'fallback content with mixed named/unnamed slots' , function ( ) {
63
+ el . innerHTML = '<p slot="b">slot b</p>'
64
+ options . template =
65
+ '<slot><p>fallback a</p></slot>' +
66
+ '<slot name="b">fallback b</slot>'
67
+ mount ( )
68
+ expect ( el . childNodes . length ) . toBe ( 2 )
69
+ expect ( el . firstChild . textContent ) . toBe ( 'fallback a' )
70
+ expect ( el . lastChild . textContent ) . toBe ( 'slot b' )
71
+ } )
72
+
62
73
it ( 'selector matching multiple elements' , function ( ) {
63
74
el . innerHTML = '<p slot="t">1</p><div></div><p slot="t">2</p>'
64
75
options . template = '<slot name="t"></slot>'
You can’t perform that action at this time.
0 commit comments