File tree Expand file tree Collapse file tree 2 files changed +17
-5
lines changed
test/unit/specs/directives/element Expand file tree Collapse file tree 2 files changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -35,11 +35,12 @@ export default {
3535 // Default content
3636 var self = this
3737 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+ }
4344 }
4445 if ( ! host . _isCompiled ) {
4546 // 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 () {
5959 expect ( el . lastChild . textContent ) . toBe ( 'slot b' )
6060 } )
6161
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+
6273 it ( 'selector matching multiple elements' , function ( ) {
6374 el . innerHTML = '<p slot="t">1</p><div></div><p slot="t">2</p>'
6475 options . template = '<slot name="t"></slot>'
You can’t perform that action at this time.
0 commit comments