0
0
mirror of https://github.com/sveltejs/svelte.git synced 2024-11-30 00:46:29 +01:00
This commit is contained in:
Rich Harris 2018-04-18 08:13:07 -04:00
parent da6fa8581f
commit 1e9b32a48d
2 changed files with 4 additions and 4 deletions

View File

@ -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);

View File

@ -4,7 +4,7 @@ import { svelte, deindent } from "../helpers.js";
describe("create", () => {
it("should return a component constructor", () => {
const source = deindent`
<div>{{prop}}</div>
<div>{prop}</div>
`;
const component = svelte.create(source);
@ -13,7 +13,7 @@ describe("create", () => {
it("should throw error when source is invalid ", done => {
const source = deindent`
<div>{{prop}</div>
<div>{prop</div>
`;
const component = svelte.create(source, {
@ -27,7 +27,7 @@ describe("create", () => {
it("should return undefined when source is invalid ", () => {
const source = deindent`
<div>{{prop}</div>
<div>{prop</div>
`;
const component = svelte.create(source, {