Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #3824 Allow text nodes on static templates in components #3826

Merged
merged 1 commit into from
Oct 5, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/core/instance/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,10 @@ export function renderMixin (Vue: Class<Component>) {
tree = this._staticTrees[index] = this.$options.staticRenderFns[index].call(this._renderProxy)
if (Array.isArray(tree)) {
for (let i = 0; i < tree.length; i++) {
tree[i].isStatic = true
tree[i].key = `__static__${index}_${i}`
if (typeof tree[i] !== 'string') {
tree[i].isStatic = true
tree[i].key = `__static__${index}_${i}`
}
}
} else {
tree.isStatic = true
Expand Down
13 changes: 13 additions & 0 deletions test/unit/features/component/component-slot.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -523,4 +523,17 @@ describe('Component slot', () => {
expect(spy).toHaveBeenCalled()
}).then(done)
})

it('renders static tree with text', () => {
const vm = new Vue({
template: `<div><test><template><div></div>Hello<div></div></template></test></div>`,
components: {
test: {
template: '<div><slot></slot></div>'
}
}
})
vm.$mount()
expect('Error when rendering root').not.toHaveBeenWarned()
})
})