From 1e9b32a48d0cea0fa0fe3506109de79e6563ab99 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Wed, 18 Apr 2018 08:13:07 -0400 Subject: [PATCH] fixes --- src/index.ts | 2 +- test/create/index.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/index.ts b/src/index.ts index 1b9fc8fa61..a82cc48ffe 100644 --- a/src/index.ts +++ b/src/index.ts @@ -150,7 +150,7 @@ function create(source: string, _options: CompileOptions = {}) { } try { - return (new Function(compiled.js.code))(); + return (new Function(`return ${compiled.js.code}`))(); } catch (err) { if (_options.onerror) { _options.onerror(err); diff --git a/test/create/index.js b/test/create/index.js index 3c2387d737..cb4beb623a 100644 --- a/test/create/index.js +++ b/test/create/index.js @@ -4,7 +4,7 @@ import { svelte, deindent } from "../helpers.js"; describe("create", () => { it("should return a component constructor", () => { const source = deindent` -
{{prop}}
+
{prop}
`; const component = svelte.create(source); @@ -13,7 +13,7 @@ describe("create", () => { it("should throw error when source is invalid ", done => { const source = deindent` -
{{prop}
+
{prop
`; const component = svelte.create(source, { @@ -27,7 +27,7 @@ describe("create", () => { it("should return undefined when source is invalid ", () => { const source = deindent` -
{{prop}
+
{prop
`; const component = svelte.create(source, {