File tree Expand file tree Collapse file tree 2 files changed +16
-5
lines changed Expand file tree Collapse file tree 2 files changed +16
-5
lines changed Original file line number Diff line number Diff line change @@ -87,11 +87,13 @@ function transcludeContent (el, raw) {
87
87
select = outlet . getAttribute ( 'select' )
88
88
if ( select ) { // select content
89
89
selected = raw . querySelectorAll ( select )
90
- outlet . content = _ . toArray (
91
- selected . length
92
- ? selected
93
- : outlet . childNodes
94
- )
90
+ if ( selected . length ) {
91
+ outlet . content = _ . toArray ( selected ) . filter ( function ( element ) {
92
+ return element . parentNode === raw
93
+ } )
94
+ } else {
95
+ outlet . content = _ . toArray ( outlet . childNodes )
96
+ }
95
97
} else { // default content
96
98
main = outlet
97
99
}
Original file line number Diff line number Diff line change @@ -109,5 +109,14 @@ if (_.inBrowser) {
109
109
expect ( res . childNodes [ 3 ] . tagName ) . toBe ( 'SPAN' )
110
110
} )
111
111
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>'
115
+ var res = transclude ( el , options )
116
+ expect ( res . childNodes . length ) . toBe ( 2 )
117
+ expect ( res . firstChild . textContent ) . toBe ( 'fallback a' )
118
+ expect ( res . lastChild . textContent ) . toBe ( 'select b' )
119
+ } )
120
+
112
121
} )
113
122
}
You can’t perform that action at this time.
0 commit comments