Skip to content

Commit c835ce5

Browse files
posvayyx990803
authored andcommitted
Allow text nodes on static templates in components (#3826)
Fix #3824
1 parent e6d224c commit c835ce5

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/core/instance/render.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,10 @@ export function renderMixin (Vue: Class<Component>) {
117117
tree = this._staticTrees[index] = this.$options.staticRenderFns[index].call(this._renderProxy)
118118
if (Array.isArray(tree)) {
119119
for (let i = 0; i < tree.length; i++) {
120-
tree[i].isStatic = true
121-
tree[i].key = `__static__${index}_${i}`
120+
if (typeof tree[i] !== 'string') {
121+
tree[i].isStatic = true
122+
tree[i].key = `__static__${index}_${i}`
123+
}
122124
}
123125
} else {
124126
tree.isStatic = true

test/unit/features/component/component-slot.spec.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,4 +523,17 @@ describe('Component slot', () => {
523523
expect(spy).toHaveBeenCalled()
524524
}).then(done)
525525
})
526+
527+
it('renders static tree with text', () => {
528+
const vm = new Vue({
529+
template: `<div><test><template><div></div>Hello<div></div></template></test></div>`,
530+
components: {
531+
test: {
532+
template: '<div><slot></slot></div>'
533+
}
534+
}
535+
})
536+
vm.$mount()
537+
expect('Error when rendering root').not.toHaveBeenWarned()
538+
})
526539
})

0 commit comments

Comments
 (0)