File tree Expand file tree Collapse file tree 2 files changed +30
-1
lines changed
Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Original file line number Diff line number Diff line change 11var _ = require ( '../util' )
2+ var config = require ( '../config' )
23var templateParser = require ( '../parsers/template' )
34var transcludedFlagAttr = '__vue__transcluded'
45
@@ -73,7 +74,13 @@ function transcludeTemplate (el, options) {
7374 } else {
7475 var rawContent = options . _content || _ . extractContent ( el )
7576 if ( options . replace ) {
76- if ( frag . childNodes . length > 1 ) {
77+ if (
78+ frag . childNodes . length > 1 ||
79+ // when root node has v-repeat, the instance ends up
80+ // having multiple top-level nodes, thus becoming a
81+ // block instance. (#835)
82+ frag . firstChild . hasAttribute ( config . prefix + 'repeat' )
83+ ) {
7784 transcludeContent ( frag , rawContent )
7885 return frag
7986 } else {
Original file line number Diff line number Diff line change @@ -47,4 +47,26 @@ describe('Misc', function () {
4747 expect ( spy2 ) . toHaveBeenCalled ( )
4848 } )
4949
50+ it ( 'v-repeat on component root node with replace:true' , function ( ) {
51+ var el = document . createElement ( 'div' )
52+ var vm = new Vue ( {
53+ el : el ,
54+ template : '<div v-component="test"></div>' ,
55+ components : {
56+ test : {
57+ data : function ( ) {
58+ return { list : [ 1 , 2 , 3 ] }
59+ } ,
60+ template : '<div v-repeat="list">{{$value}}</div>' ,
61+ replace : true
62+ }
63+ }
64+ } )
65+ expect ( vm . $el . innerHTML ) . toBe (
66+ '<!--v-start-->' +
67+ '<div>1</div><div>2</div><div>3</div><!--v-repeat-->' +
68+ '<!--v-end--><!--v-component-->'
69+ )
70+ } )
71+
5072} )
You can’t perform that action at this time.
0 commit comments