fix(vue): properly cache runtime compilation

This commit is contained in:
Evan You
2019-12-11 09:46:42 -05:00
parent 559fa27185
commit d3d4fe84cd
4 changed files with 68 additions and 22 deletions

View File

@@ -4,7 +4,7 @@ import { mockWarn } from '@vue/runtime-test'
describe('compiler + runtime integration', () => {
mockWarn()
it('should support on-the-fly template compilation', () => {
it('should support runtime template compilation', () => {
const container = document.createElement('div')
const App = {
template: `{{ count }}`,
@@ -18,6 +18,43 @@ describe('compiler + runtime integration', () => {
expect(container.innerHTML).toBe(`0`)
})
it('should support runtime template via CSS ID selector', () => {
const container = document.createElement('div')
const template = document.createElement('div')
template.id = 'template'
template.innerHTML = '{{ count }}'
document.body.appendChild(template)
const App = {
template: `#template`,
data() {
return {
count: 0
}
}
}
createApp().mount(App, container)
expect(container.innerHTML).toBe(`0`)
})
it('should support runtime template via direct DOM node', () => {
const container = document.createElement('div')
const template = document.createElement('div')
template.id = 'template'
template.innerHTML = '{{ count }}'
const App = {
template,
data() {
return {
count: 0
}
}
}
createApp().mount(App, container)
expect(container.innerHTML).toBe(`0`)
})
it('should warn template compilation errors with codeframe', () => {
const container = document.createElement('div')
const App = {