Skip to content

Instantly share code, notes, and snippets.

@earnubs
Created October 10, 2019 14:03
Show Gist options
  • Save earnubs/87e6e54cf29d346dbb2305183fca7dd8 to your computer and use it in GitHub Desktop.
Save earnubs/87e6e54cf29d346dbb2305183fca7dd8 to your computer and use it in GitHub Desktop.
vue-test-utils patch
diff --git a/packages/shared/compile-template.js b/packages/shared/compile-template.js
index f505702..8ace3db 100644
--- a/packages/shared/compile-template.js
+++ b/packages/shared/compile-template.js
@@ -17,6 +17,18 @@ 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))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment