File tree Expand file tree Collapse file tree 2 files changed +10
-8
lines changed Expand file tree Collapse file tree 2 files changed +10
-8
lines changed Original file line number Diff line number Diff line change @@ -88,12 +88,13 @@ function transcludeContent (el, raw) {
88
88
if ( select ) { // select content
89
89
selected = raw . querySelectorAll ( select )
90
90
if ( selected . length ) {
91
- outlet . content = _ . toArray ( selected ) . filter ( function ( element ) {
92
- return element . parentNode === raw
91
+ selected = _ . toArray ( selected ) . filter ( function ( node ) {
92
+ return node . parentNode === raw
93
93
} )
94
- } else {
95
- outlet . content = _ . toArray ( outlet . childNodes )
96
94
}
95
+ outlet . content = selected . length
96
+ ? selected
97
+ : _ . toArray ( outlet . childNodes )
97
98
} else { // default content
98
99
main = outlet
99
100
}
Original file line number Diff line number Diff line change @@ -110,12 +110,13 @@ if (_.inBrowser) {
110
110
} )
111
111
112
112
it ( 'select should only match children' , function ( ) {
113
- el . innerHTML = '<p class="b">select b</p><span><p class="b">nested b</p></span>'
114
- options . template = '<content select=".a"><p>fallback a</p></content><content select=".b">fallback b</content>'
113
+ el . innerHTML = '<p class="b">select b</p><span><p class="b">nested b</p></span><span><p class="c">nested c</p></span> '
114
+ options . template = '<content select=".a"><p>fallback a</p></content><content select=".b">fallback b</content><content select=".c">fallback c</content> '
115
115
var res = transclude ( el , options )
116
- expect ( res . childNodes . length ) . toBe ( 2 )
116
+ expect ( res . childNodes . length ) . toBe ( 3 )
117
117
expect ( res . firstChild . textContent ) . toBe ( 'fallback a' )
118
- expect ( res . lastChild . textContent ) . toBe ( 'select b' )
118
+ expect ( res . childNodes [ 1 ] . textContent ) . toBe ( 'select b' )
119
+ expect ( res . lastChild . textContent ) . toBe ( 'fallback c' )
119
120
} )
120
121
121
122
} )
You can’t perform that action at this time.
0 commit comments