remove v2 options

pull/1864/head
Rich Harris 7 years ago
parent 829a64923c
commit a2498bb334

@ -46,16 +46,6 @@ function validate_options(options: CompileOptions, stats: Stats) {
} }
export default function compile(source: string, options: CompileOptions = {}) { export default function compile(source: string, options: CompileOptions = {}) {
const onerror = options.onerror || (err => {
throw err;
});
if (options.onerror) {
// TODO remove in v3
deprecate(`Instead of using options.onerror, wrap svelte.compile in a try-catch block`);
delete options.onerror;
}
options = normalize_options(options); options = normalize_options(options);
const stats = new Stats({ const stats = new Stats({
@ -64,7 +54,6 @@ export default function compile(source: string, options: CompileOptions = {}) {
let ast: Ast; let ast: Ast;
try {
validate_options(options, stats); validate_options(options, stats);
stats.start('parse'); stats.start('parse');
@ -90,7 +79,4 @@ export default function compile(source: string, options: CompileOptions = {}) {
} }
return renderDOM(component, options); return renderDOM(component, options);
} catch (err) {
onerror(err);
}
} }

@ -18,9 +18,7 @@ export default function dom(
const { block } = renderer; const { block } = renderer;
if (component.options.nestedTransitions) {
block.hasOutroMethod = true; block.hasOutroMethod = true;
}
// prevent fragment being created twice (#1063) // prevent fragment being created twice (#1063)
if (options.customElement) block.builders.create.addLine(`this.c = @noop;`); if (options.customElement) block.builders.create.addLine(`this.c = @noop;`);

@ -112,7 +112,7 @@ export default class AwaitBlockWrapper extends Wrapper {
this.then.block.hasOutroMethod = hasOutros; this.then.block.hasOutroMethod = hasOutros;
this.catch.block.hasOutroMethod = hasOutros; this.catch.block.hasOutroMethod = hasOutros;
if (hasOutros && this.renderer.options.nestedTransitions) { if (hasOutros) {
block.addOutro(); block.addOutro();
} }
} }
@ -206,7 +206,7 @@ export default class AwaitBlockWrapper extends Wrapper {
`); `);
} }
if (this.pending.block.hasOutroMethod && this.renderer.options.nestedTransitions) { if (this.pending.block.hasOutroMethod) {
const countdown = block.getUniqueName('countdown'); const countdown = block.getUniqueName('countdown');
block.builders.outro.addBlock(deindent` block.builders.outro.addBlock(deindent`
const ${countdown} = @callAfter(#outrocallback, 3); const ${countdown} = @callAfter(#outrocallback, 3);

@ -344,7 +344,7 @@ export default class EachBlockWrapper extends Wrapper {
${this.node.hasAnimation && `for (let #i = 0; #i < ${blocks}.length; #i += 1) ${blocks}[#i].a();`} ${this.node.hasAnimation && `for (let #i = 0; #i < ${blocks}.length; #i += 1) ${blocks}[#i].a();`}
`); `);
if (this.block.hasOutros && this.renderer.component.options.nestedTransitions) { if (this.block.hasOutros) {
const countdown = block.getUniqueName('countdown'); const countdown = block.getUniqueName('countdown');
block.builders.outro.addBlock(deindent` block.builders.outro.addBlock(deindent`
const ${countdown} = @callAfter(#outrocallback, ${blocks}.length); const ${countdown} = @callAfter(#outrocallback, ${blocks}.length);
@ -501,7 +501,7 @@ export default class EachBlockWrapper extends Wrapper {
} }
} }
if (outroBlock && this.renderer.component.options.nestedTransitions) { if (outroBlock) {
const countdown = block.getUniqueName('countdown'); const countdown = block.getUniqueName('countdown');
block.builders.outro.addBlock(deindent` block.builders.outro.addBlock(deindent`
${iterations} = ${iterations}.filter(Boolean); ${iterations} = ${iterations}.filter(Boolean);

@ -125,10 +125,8 @@ export default class IfBlockWrapper extends Wrapper {
createBranches(this.node); createBranches(this.node);
if (component.options.nestedTransitions) {
if (hasIntros) block.addIntro(); if (hasIntros) block.addIntro();
if (hasOutros) block.addOutro(); if (hasOutros) block.addOutro();
}
blocks.forEach(block => { blocks.forEach(block => {
block.hasUpdateMethod = isDynamic; block.hasUpdateMethod = isDynamic;
@ -163,19 +161,17 @@ export default class IfBlockWrapper extends Wrapper {
if (hasOutros) { if (hasOutros) {
this.renderCompoundWithOutros(block, parentNode, parentNodes, dynamic, vars); this.renderCompoundWithOutros(block, parentNode, parentNodes, dynamic, vars);
if (this.renderer.options.nestedTransitions) {
block.builders.outro.addBlock(deindent` block.builders.outro.addBlock(deindent`
if (${name}) ${name}.o(#outrocallback); if (${name}) ${name}.o(#outrocallback);
else #outrocallback(); else #outrocallback();
`); `);
}
} else { } else {
this.renderCompound(block, parentNode, parentNodes, dynamic, vars); this.renderCompound(block, parentNode, parentNodes, dynamic, vars);
} }
} else { } else {
this.renderSimple(block, parentNode, parentNodes, dynamic, vars); this.renderSimple(block, parentNode, parentNodes, dynamic, vars);
if (hasOutros && this.renderer.options.nestedTransitions) { if (hasOutros) {
block.builders.outro.addBlock(deindent` block.builders.outro.addBlock(deindent`
if (${name}) ${name}.o(#outrocallback); if (${name}) ${name}.o(#outrocallback);
else #outrocallback(); else #outrocallback();

@ -68,10 +68,8 @@ export default class InlineComponentWrapper extends Wrapper {
this.fragment = new FragmentWrapper(renderer, block, node.children, this, stripWhitespace, nextSibling); this.fragment = new FragmentWrapper(renderer, block, node.children, this, stripWhitespace, nextSibling);
} }
if (renderer.component.options.nestedTransitions) {
block.addOutro(); block.addOutro();
} }
}
render( render(
block: Block, block: Block,
@ -318,14 +316,11 @@ export default class InlineComponentWrapper extends Wrapper {
block.builders.update.addBlock(deindent` block.builders.update.addBlock(deindent`
if (${switch_value} !== (${switch_value} = ${snippet})) { if (${switch_value} !== (${switch_value} = ${snippet})) {
if (${name}) { if (${name}) {
${component.options.nestedTransitions
? deindent`
@groupOutros(); @groupOutros();
const old_component = ${name}; const old_component = ${name};
old_component.$$fragment.o(() => { old_component.$$fragment.o(() => {
old_component.$destroy(); old_component.$destroy();
});` });
: `${name}.$destroy();`}
} }
if (${switch_value}) { if (${switch_value}) {
@ -409,12 +404,10 @@ export default class InlineComponentWrapper extends Wrapper {
`); `);
} }
if (component.options.nestedTransitions) {
block.builders.outro.addLine( block.builders.outro.addLine(
`if (${name}) ${name}.$$fragment.o(#outrocallback);` `if (${name}) ${name}.$$fragment.o(#outrocallback);`
); );
} }
}
remount(name: string) { remount(name: string) {
return `${this.var}.$$mount(${name}.$$slotted.default, null);`; return `${this.var}.$$mount(${name}.$$slotted.default, null);`;

@ -3,19 +3,8 @@ import { CompileOptions } from './interfaces';
import deprecate from './utils/deprecate'; import deprecate from './utils/deprecate';
export function create(source: string, options: CompileOptions = {}) { export function create(source: string, options: CompileOptions = {}) {
const onerror = options.onerror || (err => {
throw err;
});
if (options.onerror) {
// TODO remove in v3
deprecate(`Instead of using options.onerror, wrap svelte.create in a try-catch block`);
delete options.onerror;
}
options.format = 'eval'; options.format = 'eval';
try {
const compiled = compile(source, options); const compiled = compile(source, options);
if (!compiled || !compiled.js.code) { if (!compiled || !compiled.js.code) {
@ -23,9 +12,6 @@ export function create(source: string, options: CompileOptions = {}) {
} }
return (new Function(`return ${compiled.js.code}`))(); return (new Function(`return ${compiled.js.code}`))();
} catch (err) {
onerror(err);
}
} }
export { default as compile } from './compile/index'; export { default as compile } from './compile/index';

@ -61,11 +61,6 @@ export interface CompileOptions {
preserveComments?: boolean | false; preserveComments?: boolean | false;
onwarn?: (warning: Warning) => void; onwarn?: (warning: Warning) => void;
// to remove in v3
onerror?: (error: Error) => void;
skipIntroByDefault?: boolean;
nestedTransitions?: boolean;
} }
export interface Visitor { export interface Visitor {

Loading…
Cancel
Save