pull/1348/head
Rich Harris 6 years ago
parent da6fa8581f
commit 1e9b32a48d

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

@ -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, {

Loading…
Cancel
Save