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 = {
36
36
} else {
37
37
// select content
38
38
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
+ }
45
51
}
46
52
}
47
53
} ,
Original file line number Diff line number Diff line change @@ -54,6 +54,13 @@ describe('Content Transclusion', function () {
54
54
expect ( el . lastChild . textContent ) . toBe ( 'select b' )
55
55
} )
56
56
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
+
57
64
it ( 'content transclusion with replace' , function ( ) {
58
65
el . innerHTML = '<p>hi</p>'
59
66
options . template = '<div><div><content></content></div></div>'
You can’t perform that action at this time.
0 commit comments