diff --git a/packages/shared/compile-template.js b/packages/shared/compile-template.js index f5057024f..7999894bc 100644 --- a/packages/shared/compile-template.js +++ b/packages/shared/compile-template.js @@ -17,6 +17,16 @@ export function compileFromString(str: string) { export function compileTemplate(component: Component): void { if (component.template) { + if (component.template.charAt('#') === '#') { + var el = document.querySelector(component.template) + if (!el) { + throwError('Cannot find element' + component.template) + + el = document.createElement('div') + } + component.template = el.innerHTML + } + Object.assign(component, compileToFunctions(component.template)) } diff --git a/test/specs/mount.spec.js b/test/specs/mount.spec.js index 9bf2493d7..3a7a78fb3 100644 --- a/test/specs/mount.spec.js +++ b/test/specs/mount.spec.js @@ -161,6 +161,25 @@ describeRunIf(process.env.TEST_ENV !== 'node', 'mount', () => { expect(wrapper.html()).to.equal(`