fix some stuff

pull/1971/head
Richard Harris 7 years ago
parent 266d9de613
commit 54ee383f36

@ -442,8 +442,8 @@ export default class EachBlockWrapper extends Wrapper {
${iterations}[#i] = ${create_each_block}($$, child_ctx);
${iterations}[#i].c();
${iterations}[#i].m(${updateMountNode}, ${anchor});
${has_transitions && `${iterations}[#i].i();`}
}
${has_transitions && `${iterations}[#i].i();`}
`
: deindent`
${iterations}[#i] = ${create_each_block}($$, child_ctx);

@ -153,6 +153,7 @@ export default class IfBlockWrapper extends Wrapper {
const if_name = hasElse ? '' : `if (${name}) `;
const dynamic = this.branches[0].block.hasUpdateMethod; // can use [0] as proxy for all, since they necessarily have the same value
const hasIntros = this.branches[0].block.hasIntroMethod;
const hasOutros = this.branches[0].block.hasOutroMethod;
const vars = { name, anchor, if_name, hasElse };
@ -181,6 +182,10 @@ export default class IfBlockWrapper extends Wrapper {
);
}
if (hasIntros || hasOutros) {
block.builders.intro.addLine(`if (${name}) ${name}.i();`);
}
if (needsAnchor) {
block.addElement(
anchor,
@ -230,8 +235,11 @@ export default class IfBlockWrapper extends Wrapper {
const changeBlock = deindent`
${if_name}${name}.d(1);
${name} = ${current_block_type_and}${current_block_type}($$, ctx);
${if_name}${name}.c();
${if_name}${name}.m(${updateMountNode}, ${anchor});
if (${name}) {
${name}.c();
${name}.m(${updateMountNode}, ${anchor});
${this.branches[0].block.hasIntroMethod && `${name}.i();`}
}
`;
if (dynamic) {
@ -435,10 +443,6 @@ export default class IfBlockWrapper extends Wrapper {
${name} = null;
`;
if (has_transitions) {
block.builders.intro.addLine(`if (${name}) ${name}.i();`);
}
block.builders.update.addBlock(deindent`
if (${branch.condition}) {
${enter}

@ -13,7 +13,6 @@ import {
setupHtmlEqual
} from "../helpers.js";
const main = path.resolve('index.js');
let svelte$;
let svelte;
@ -28,7 +27,7 @@ function getName(filename) {
const sveltePath = process.cwd().split('\\').join('/');
const internal = `${sveltePath}/internal.js`;
describe("runtime", () => {
describe.only("runtime", () => {
before(() => {
svelte = loadSvelte(false);
svelte$ = loadSvelte(true);

@ -1,7 +1,7 @@
export default {
intro: true,
test({ assert, component, target, window, raf }) {
test({ assert, component, target, raf }) {
assert.equal(target.querySelector('div'), component.no);
assert.equal(component.no.foo, 0);

Loading…
Cancel
Save