File tree Expand file tree Collapse file tree 2 files changed +19
-6
lines changed Expand file tree Collapse file tree 2 files changed +19
-6
lines changed Original file line number Diff line number Diff line change @@ -36,12 +36,18 @@ module.exports = {
3636 } else {
3737 // select content
3838 selector = vm . $interpolate ( selector )
39- content = raw . querySelector ( selector )
40- // only allow top-level select
41- if ( content && content . parentNode === raw ) {
42- // same deal, clone the node for v-if
43- content = content . cloneNode ( true )
44- this . compile ( content , parent , vm )
39+ var nodes = raw . querySelectorAll ( selector )
40+ if ( nodes . length ) {
41+ content = document . createDocumentFragment ( )
42+ for ( var i = 0 , l = nodes . length ; i < l ; i ++ ) {
43+ // only allow top-level select
44+ if ( nodes [ i ] . parentNode === raw ) {
45+ content . appendChild ( nodes [ i ] . cloneNode ( true ) )
46+ }
47+ }
48+ if ( content . hasChildNodes ( ) ) {
49+ this . compile ( content , parent , vm )
50+ }
4551 }
4652 }
4753 } ,
Original file line number Diff line number Diff line change @@ -54,6 +54,13 @@ describe('Content Transclusion', function () {
5454 expect ( el . lastChild . textContent ) . toBe ( 'select b' )
5555 } )
5656
57+ it ( 'selector matching multiple elements' , function ( ) {
58+ el . innerHTML = '<p class="t">1</p><div></div><p class="t">2</p>'
59+ options . template = '<content select=".t"></content>'
60+ mount ( )
61+ expect ( el . innerHTML ) . toBe ( '<p class="t">1</p><p class="t">2</p>' )
62+ } )
63+
5764 it ( 'content transclusion with replace' , function ( ) {
5865 el . innerHTML = '<p>hi</p>'
5966 options . template = '<div><div><content></content></div></div>'
You can’t perform that action at this time.
0 commit comments