keep ES5 function names in dev mode

pull/1388/head
Rich Harris 7 years ago
parent a29e2733cd
commit da2a45af80

@ -140,6 +140,8 @@ export default class Block {
} }
toString() { toString() {
const { dev } = this.compiler.options;
let introing; let introing;
const hasIntros = !this.builders.intro.isEmpty(); const hasIntros = !this.builders.intro.isEmpty();
if (hasIntros) { if (hasIntros) {
@ -184,7 +186,7 @@ export default class Block {
); );
properties.addBlock(deindent` properties.addBlock(deindent`
c() { ${dev ? 'c: function create' : 'c'}() {
${this.builders.create} ${this.builders.create}
${hydrate} ${hydrate}
}, },
@ -196,7 +198,7 @@ export default class Block {
properties.addBlock(`l: @noop,`); properties.addBlock(`l: @noop,`);
} else { } else {
properties.addBlock(deindent` properties.addBlock(deindent`
l(nodes) { ${dev ? 'l: function claim' : 'l'}(nodes) {
${this.builders.claim} ${this.builders.claim}
${!this.builders.hydrate.isEmpty() && `this.h();`} ${!this.builders.hydrate.isEmpty() && `this.h();`}
}, },
@ -206,7 +208,7 @@ export default class Block {
if (this.compiler.options.hydratable && !this.builders.hydrate.isEmpty()) { if (this.compiler.options.hydratable && !this.builders.hydrate.isEmpty()) {
properties.addBlock(deindent` properties.addBlock(deindent`
h() { ${dev ? 'h: function hydrate' : 'h'}() {
${this.builders.hydrate} ${this.builders.hydrate}
}, },
`); `);
@ -216,7 +218,7 @@ export default class Block {
properties.addBlock(`m: @noop,`); properties.addBlock(`m: @noop,`);
} else { } else {
properties.addBlock(deindent` properties.addBlock(deindent`
m(#target, anchor) { ${dev ? 'm: function mount' : 'm'}(#target, anchor) {
${this.builders.mount} ${this.builders.mount}
}, },
`); `);
@ -227,7 +229,7 @@ export default class Block {
properties.addBlock(`p: @noop,`); properties.addBlock(`p: @noop,`);
} else { } else {
properties.addBlock(deindent` properties.addBlock(deindent`
p(changed, ${this.maintainContext ? '_ctx' : 'ctx'}) { ${dev ? 'p: function update' : 'p'}(changed, ${this.maintainContext ? '_ctx' : 'ctx'}) {
${this.maintainContext && `ctx = _ctx;`} ${this.maintainContext && `ctx = _ctx;`}
${this.builders.update} ${this.builders.update}
}, },
@ -238,7 +240,7 @@ export default class Block {
if (this.hasIntroMethod) { if (this.hasIntroMethod) {
if (hasIntros) { if (hasIntros) {
properties.addBlock(deindent` properties.addBlock(deindent`
i(#target, anchor) { ${dev ? 'i: function intro' : 'i'}(#target, anchor) {
if (${introing}) return; if (${introing}) return;
${introing} = true; ${introing} = true;
${hasOutros && `${outroing} = false;`} ${hasOutros && `${outroing} = false;`}
@ -250,7 +252,7 @@ export default class Block {
`); `);
} else { } else {
properties.addBlock(deindent` properties.addBlock(deindent`
i(#target, anchor) { ${dev ? 'i: function intro' : 'i'}(#target, anchor) {
this.m(#target, anchor); this.m(#target, anchor);
}, },
`); `);
@ -260,7 +262,7 @@ export default class Block {
if (this.hasOutroMethod) { if (this.hasOutroMethod) {
if (hasOutros) { if (hasOutros) {
properties.addBlock(deindent` properties.addBlock(deindent`
o(#outrocallback) { ${dev ? 'o: function outro' : 'o'}(#outrocallback) {
if (${outroing}) return; if (${outroing}) return;
${outroing} = true; ${outroing} = true;
${hasIntros && `${introing} = false;`} ${hasIntros && `${introing} = false;`}
@ -281,7 +283,7 @@ export default class Block {
properties.addBlock(`u: @noop,`); properties.addBlock(`u: @noop,`);
} else { } else {
properties.addBlock(deindent` properties.addBlock(deindent`
u() { ${dev ? 'u: function unmount' : 'u'}() {
${this.builders.unmount} ${this.builders.unmount}
}, },
`); `);
@ -291,7 +293,7 @@ export default class Block {
properties.addBlock(`d: @noop`); properties.addBlock(`d: @noop`);
} else { } else {
properties.addBlock(deindent` properties.addBlock(deindent`
d() { ${dev ? 'd: function destroy' : 'd'}() {
${this.builders.destroy} ${this.builders.destroy}
} }
`); `);

@ -169,21 +169,21 @@ function create_main_fragment(component, ctx) {
var p, text_value = ctx.Math.max(0, ctx.foo), text, text_1, text_2; var p, text_value = ctx.Math.max(0, ctx.foo), text, text_1, text_2;
return { return {
c() { c: function create() {
p = createElement("p"); p = createElement("p");
text = createText(text_value); text = createText(text_value);
text_1 = createText("\n\t"); text_1 = createText("\n\t");
text_2 = createText(ctx.bar); text_2 = createText(ctx.bar);
}, },
m(target, anchor) { m: function mount(target, anchor) {
insertNode(p, target, anchor); insertNode(p, target, anchor);
appendNode(text, p); appendNode(text, p);
appendNode(text_1, p); appendNode(text_1, p);
appendNode(text_2, p); appendNode(text_2, p);
}, },
p(changed, ctx) { p: function update(changed, ctx) {
if ((changed.Math || changed.foo) && text_value !== (text_value = ctx.Math.max(0, ctx.foo))) { if ((changed.Math || changed.foo) && text_value !== (text_value = ctx.Math.max(0, ctx.foo))) {
text.data = text_value; text.data = text_value;
} }
@ -193,7 +193,7 @@ function create_main_fragment(component, ctx) {
} }
}, },
u() { u: function unmount() {
detachNode(p); detachNode(p);
}, },

@ -9,21 +9,21 @@ function create_main_fragment(component, ctx) {
var p, text_value = ctx.Math.max(0, ctx.foo), text, text_1, text_2; var p, text_value = ctx.Math.max(0, ctx.foo), text, text_1, text_2;
return { return {
c() { c: function create() {
p = createElement("p"); p = createElement("p");
text = createText(text_value); text = createText(text_value);
text_1 = createText("\n\t"); text_1 = createText("\n\t");
text_2 = createText(ctx.bar); text_2 = createText(ctx.bar);
}, },
m(target, anchor) { m: function mount(target, anchor) {
insertNode(p, target, anchor); insertNode(p, target, anchor);
appendNode(text, p); appendNode(text, p);
appendNode(text_1, p); appendNode(text_1, p);
appendNode(text_2, p); appendNode(text_2, p);
}, },
p(changed, ctx) { p: function update(changed, ctx) {
if ((changed.Math || changed.foo) && text_value !== (text_value = ctx.Math.max(0, ctx.foo))) { if ((changed.Math || changed.foo) && text_value !== (text_value = ctx.Math.max(0, ctx.foo))) {
text.data = text_value; text.data = text_value;
} }
@ -33,7 +33,7 @@ function create_main_fragment(component, ctx) {
} }
}, },
u() { u: function unmount() {
detachNode(p); detachNode(p);
}, },

Loading…
Cancel
Save