File tree Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -28,8 +28,14 @@ exports.transclude = function (el, options) {
28
28
if ( _ . isTemplate ( el ) ) {
29
29
el = templateParser . parse ( el )
30
30
}
31
- if ( options && options . template ) {
32
- el = transcludeTemplate ( el , options )
31
+ if ( options ) {
32
+ if ( options . _asComponent && ! options . template ) {
33
+ options . template = '<content></content>'
34
+ }
35
+ if ( options . template ) {
36
+ options . _content = _ . extractContent ( el )
37
+ el = transcludeTemplate ( el , options )
38
+ }
33
39
}
34
40
if ( el instanceof DocumentFragment ) {
35
41
// anchors for block instance
@@ -56,7 +62,6 @@ function transcludeTemplate (el, options) {
56
62
if ( ! frag ) {
57
63
_ . warn ( 'Invalid template option: ' + template )
58
64
} else {
59
- options . _content = _ . extractContent ( el )
60
65
var replacer = frag . firstChild
61
66
if ( options . replace ) {
62
67
if (
@@ -121,4 +126,4 @@ function mergeAttrs (from, to) {
121
126
to . className = to . className + ' ' + value
122
127
}
123
128
}
124
- }
129
+ }
Original file line number Diff line number Diff line change @@ -30,6 +30,14 @@ describe('Content Transclusion', function () {
30
30
expect ( el . firstChild . firstChild . textContent ) . toBe ( 'hi' )
31
31
} )
32
32
33
+ it ( 'no template auto content' , function ( ) {
34
+ el . innerHTML = '<p>hi</p>'
35
+ options . _asComponent = true
36
+ mount ( )
37
+ expect ( el . firstChild . tagName ) . toBe ( 'P' )
38
+ expect ( el . firstChild . textContent ) . toBe ( 'hi' )
39
+ } )
40
+
33
41
it ( 'fallback content' , function ( ) {
34
42
options . template = '<content><p>fallback</p></content>'
35
43
mount ( )
You can’t perform that action at this time.
0 commit comments