|
|
@ -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) {
|
|
|
@ -177,10 +179,16 @@ export default class Block {
|
|
|
|
if (this.builders.create.isEmpty() && this.builders.hydrate.isEmpty()) {
|
|
|
|
if (this.builders.create.isEmpty() && this.builders.hydrate.isEmpty()) {
|
|
|
|
properties.addBlock(`c: @noop,`);
|
|
|
|
properties.addBlock(`c: @noop,`);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
|
|
|
|
const hydrate = !this.builders.hydrate.isEmpty() && (
|
|
|
|
|
|
|
|
this.compiler.options.hydratable
|
|
|
|
|
|
|
|
? `this.h()`
|
|
|
|
|
|
|
|
: this.builders.hydrate
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
properties.addBlock(deindent`
|
|
|
|
properties.addBlock(deindent`
|
|
|
|
c: function create() {
|
|
|
|
${dev ? 'c: function create' : 'c'}() {
|
|
|
|
${this.builders.create}
|
|
|
|
${this.builders.create}
|
|
|
|
${!this.builders.hydrate.isEmpty() && `this.h();`}
|
|
|
|
${hydrate}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
`);
|
|
|
|
`);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -190,7 +198,7 @@ export default class Block {
|
|
|
|
properties.addBlock(`l: @noop,`);
|
|
|
|
properties.addBlock(`l: @noop,`);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
properties.addBlock(deindent`
|
|
|
|
properties.addBlock(deindent`
|
|
|
|
l: function claim(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();`}
|
|
|
|
},
|
|
|
|
},
|
|
|
@ -198,9 +206,9 @@ export default class Block {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!this.builders.hydrate.isEmpty()) {
|
|
|
|
if (this.compiler.options.hydratable && !this.builders.hydrate.isEmpty()) {
|
|
|
|
properties.addBlock(deindent`
|
|
|
|
properties.addBlock(deindent`
|
|
|
|
h: function hydrate() {
|
|
|
|
${dev ? 'h: function hydrate' : 'h'}() {
|
|
|
|
${this.builders.hydrate}
|
|
|
|
${this.builders.hydrate}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
`);
|
|
|
|
`);
|
|
|
@ -210,7 +218,7 @@ export default class Block {
|
|
|
|
properties.addBlock(`m: @noop,`);
|
|
|
|
properties.addBlock(`m: @noop,`);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
properties.addBlock(deindent`
|
|
|
|
properties.addBlock(deindent`
|
|
|
|
m: function mount(#target, anchor) {
|
|
|
|
${dev ? 'm: function mount' : 'm'}(#target, anchor) {
|
|
|
|
${this.builders.mount}
|
|
|
|
${this.builders.mount}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
`);
|
|
|
|
`);
|
|
|
@ -221,7 +229,7 @@ export default class Block {
|
|
|
|
properties.addBlock(`p: @noop,`);
|
|
|
|
properties.addBlock(`p: @noop,`);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
properties.addBlock(deindent`
|
|
|
|
properties.addBlock(deindent`
|
|
|
|
p: function update(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}
|
|
|
|
},
|
|
|
|
},
|
|
|
@ -232,7 +240,7 @@ export default class Block {
|
|
|
|
if (this.hasIntroMethod) {
|
|
|
|
if (this.hasIntroMethod) {
|
|
|
|
if (hasIntros) {
|
|
|
|
if (hasIntros) {
|
|
|
|
properties.addBlock(deindent`
|
|
|
|
properties.addBlock(deindent`
|
|
|
|
i: function intro(#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;`}
|
|
|
@ -244,7 +252,7 @@ export default class Block {
|
|
|
|
`);
|
|
|
|
`);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
properties.addBlock(deindent`
|
|
|
|
properties.addBlock(deindent`
|
|
|
|
i: function intro(#target, anchor) {
|
|
|
|
${dev ? 'i: function intro' : 'i'}(#target, anchor) {
|
|
|
|
this.m(#target, anchor);
|
|
|
|
this.m(#target, anchor);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
`);
|
|
|
|
`);
|
|
|
@ -254,7 +262,7 @@ export default class Block {
|
|
|
|
if (this.hasOutroMethod) {
|
|
|
|
if (this.hasOutroMethod) {
|
|
|
|
if (hasOutros) {
|
|
|
|
if (hasOutros) {
|
|
|
|
properties.addBlock(deindent`
|
|
|
|
properties.addBlock(deindent`
|
|
|
|
o: function outro(#outrocallback) {
|
|
|
|
${dev ? 'o: function outro' : 'o'}(#outrocallback) {
|
|
|
|
if (${outroing}) return;
|
|
|
|
if (${outroing}) return;
|
|
|
|
${outroing} = true;
|
|
|
|
${outroing} = true;
|
|
|
|
${hasIntros && `${introing} = false;`}
|
|
|
|
${hasIntros && `${introing} = false;`}
|
|
|
@ -275,7 +283,7 @@ export default class Block {
|
|
|
|
properties.addBlock(`u: @noop,`);
|
|
|
|
properties.addBlock(`u: @noop,`);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
properties.addBlock(deindent`
|
|
|
|
properties.addBlock(deindent`
|
|
|
|
u: function unmount() {
|
|
|
|
${dev ? 'u: function unmount' : 'u'}() {
|
|
|
|
${this.builders.unmount}
|
|
|
|
${this.builders.unmount}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
`);
|
|
|
|
`);
|
|
|
@ -285,7 +293,7 @@ export default class Block {
|
|
|
|
properties.addBlock(`d: @noop`);
|
|
|
|
properties.addBlock(`d: @noop`);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
properties.addBlock(deindent`
|
|
|
|
properties.addBlock(deindent`
|
|
|
|
d: function destroy() {
|
|
|
|
${dev ? 'd: function destroy' : 'd'}() {
|
|
|
|
${this.builders.destroy}
|
|
|
|
${this.builders.destroy}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`);
|
|
|
|
`);
|
|
|
|