8000 use block instance when template contains only <content> with replace… · mikehins/vue@5e96940 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5e96940

Browse files
committed
use block instance when template contains only <content> with replace:true
1 parent b710008 commit 5e96940

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

src/compiler/transclude.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,10 @@ function transcludeTemplate (el, options) {
6767
if (
6868
frag.childNodes.length > 1 ||
6969
replacer.nodeType !== 1 ||
70-
// when root node has v-repeat, the instance ends up
71-
// having multiple top-level nodes, thus becoming a
72-
// block instance. (#835)
70+
// when root node is <content> or has v-repeat, the
71+
// instance could end up having multiple top-level
72+
// nodes, thus becoming a block instance.
73+
replacer.tagName.toLowerCase() === 'content' ||
7374
replacer.hasAttribute(config.prefix + 'repeat')
7475
) {
7576
return frag

test/unit/specs/compiler/content_spec.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,4 +260,19 @@ describe('Content Transclusion', function () {
260260
})
261261
})
262262

263+
it('single content outlet with replace: true', function () {
264+
vm = new Vue({
265+
el: el,
266+
template:
267+
'<test><p>1</p><p>2</p></test>',
268+
components: {
269+
test: {
270+
template: '<content></content>',
271+
replace: true
272+
}
273+
}
274+
})
275+
expect(el.innerHTML).toBe('<p>1</p><p>2</p>')
276+
})
277+
263278
})

0 commit comments

Comments
 (0)
0