diff --git a/src/compiler/compile/render_dom/wrappers/EachBlock.ts b/src/compiler/compile/render_dom/wrappers/EachBlock.ts index 48e7e8d0ad..126b114487 100644 --- a/src/compiler/compile/render_dom/wrappers/EachBlock.ts +++ b/src/compiler/compile/render_dom/wrappers/EachBlock.ts @@ -301,18 +301,15 @@ export default class EachBlockWrapper extends Wrapper { const has_transitions = !!(this.else.block.has_intro_method || this.else.block.has_outro_method); const destroy_block_else = this.else.block.has_outro_method - ? - b` - @group_outros(); - @transition_out(${each_block_else}, 1, 1, () => { - ${each_block_else} = null; - }); - @check_outros(); - ` - : b` - ${each_block_else}.d(1); + ? b` + @group_outros(); + @transition_out(${each_block_else}, 1, 1, () => { ${each_block_else} = null; - `; + }); + @check_outros();` + : b` + ${each_block_else}.d(1); + ${each_block_else} = null;`; if (this.else.block.has_update_method) { this.updates.push(b` @@ -328,7 +325,6 @@ export default class EachBlockWrapper extends Wrapper { } `); } else { - this.updates.push(b` if (${this.vars.data_length}) { if (${each_block_else}) { @@ -336,8 +332,8 @@ export default class EachBlockWrapper extends Wrapper { } } else if (!${each_block_else}) { ${each_block_else} = ${this.else.block.name}(#ctx); - ${each_block_else}.c(); - ${has_transitions && b`@transition_in(${each_block_else}, 1);`} + ${each_block_else}.c(); + ${has_transitions && b`@transition_in(${each_block_else}, 1);`} ${each_block_else}.m(${update_mount_node}, ${update_anchor_node}); } `); diff --git a/test/runtime/samples/transition-js-each-else-block-intro-outro/_config.js b/test/runtime/samples/transition-js-each-else-block-intro-outro/_config.js index e358808628..13d0cf0b23 100644 --- a/test/runtime/samples/transition-js-each-else-block-intro-outro/_config.js +++ b/test/runtime/samples/transition-js-each-else-block-intro-outro/_config.js @@ -1,54 +1,54 @@ export default { - props: { - things: ['a', 'b', 'c'] - }, + props: { + things: ['a', 'b', 'c'] + }, - test({ assert, component, target, window, raf }) { - component.things = []; - let div = target.querySelector('div'); - assert.equal(div.foo, 0); + test({ assert, component, target, window, raf }) { + component.things = []; + let div = target.querySelector('div'); + assert.equal(div.foo, 0); - raf.tick(200); - assert.equal(div.foo, 0.5); + raf.tick(200); + assert.equal(div.foo, 0.5); - raf.tick(300); - assert.equal(div.foo, 0.75); + raf.tick(300); + assert.equal(div.foo, 0.75); - raf.tick(400); - assert.equal(div.foo, 1); + raf.tick(400); + assert.equal(div.foo, 1); - raf.tick(600); - component.things = ['a', 'b', 'c']; + raf.tick(600); + component.things = ['a', 'b', 'c']; - raf.tick(700); - assert.equal(div.foo, 1); - assert.equal(div.bar, 0.75); + raf.tick(700); + assert.equal(div.foo, 1); + assert.equal(div.bar, 0.75); - raf.tick(800); - assert.equal(div.foo, 1); - assert.equal(div.bar, 0.5); + raf.tick(800); + assert.equal(div.foo, 1); + assert.equal(div.bar, 0.5); - raf.tick(900); - assert.equal(div.foo, 1); - assert.equal(div.bar, 0.25); + raf.tick(900); + assert.equal(div.foo, 1); + assert.equal(div.bar, 0.25); - // test outro before intro complete - raf.tick(1000); - component.things = []; - div = target.querySelector('div'); + // test outro before intro complete + raf.tick(1000); + component.things = []; + div = target.querySelector('div'); - raf.tick(1200); - assert.equal(div.foo, 0.5); + raf.tick(1200); + assert.equal(div.foo, 0.5); - component.things = ['a', 'b', 'c']; - raf.tick(1300); - assert.equal(div.foo, 0.75); - assert.equal(div.bar, 0.75); + component.things = ['a', 'b', 'c']; + raf.tick(1300); + assert.equal(div.foo, 0.75); + assert.equal(div.bar, 0.75); - raf.tick(1400); - assert.equal(div.foo, 1); - assert.equal(div.bar, 0.5); + raf.tick(1400); + assert.equal(div.foo, 1); + assert.equal(div.bar, 0.5); - raf.tick(2000); - } + raf.tick(2000); + } }; \ No newline at end of file diff --git a/test/runtime/samples/transition-js-each-else-block-intro-outro/main.svelte b/test/runtime/samples/transition-js-each-else-block-intro-outro/main.svelte index c97a916a04..1691e77f52 100644 --- a/test/runtime/samples/transition-js-each-else-block-intro-outro/main.svelte +++ b/test/runtime/samples/transition-js-each-else-block-intro-outro/main.svelte @@ -10,18 +10,18 @@ }; } - function bar(node, params) { - return { - duration: 400, - tick: t => { - node.bar = t; - } - }; - } + function bar(node, params) { + return { + duration: 400, + tick: t => { + node.bar = t; + } + }; + } {#each things as thing} -

{thing}

- {:else} -
else
+

{thing}

+{:else} +
else
{/each} \ No newline at end of file diff --git a/test/runtime/samples/transition-js-each-else-block-intro/_config.js b/test/runtime/samples/transition-js-each-else-block-intro/_config.js index 4840bb09da..f061e312ff 100644 --- a/test/runtime/samples/transition-js-each-else-block-intro/_config.js +++ b/test/runtime/samples/transition-js-each-else-block-intro/_config.js @@ -1,22 +1,22 @@ export default { - props: { - things: ['a', 'b', 'c'] - }, + props: { + things: ['a', 'b', 'c'] + }, - test({ assert, component, target, window, raf }) { - component.things = []; - const div = target.querySelector('div'); - assert.equal(div.foo, 0); + test({ assert, component, target, window, raf }) { + component.things = []; + const div = target.querySelector('div'); + assert.equal(div.foo, 0); - raf.tick(200); - assert.equal(div.foo, 0.5); + raf.tick(200); + assert.equal(div.foo, 0.5); - raf.tick(300); - assert.equal(div.foo, 0.75); + raf.tick(300); + assert.equal(div.foo, 0.75); - raf.tick(400); - assert.equal(div.foo, 1); + raf.tick(400); + assert.equal(div.foo, 1); - raf.tick(500); - } + raf.tick(500); + } }; \ No newline at end of file diff --git a/test/runtime/samples/transition-js-each-else-block-intro/main.svelte b/test/runtime/samples/transition-js-each-else-block-intro/main.svelte index eb3d4ad0d7..bda8746c46 100644 --- a/test/runtime/samples/transition-js-each-else-block-intro/main.svelte +++ b/test/runtime/samples/transition-js-each-else-block-intro/main.svelte @@ -12,7 +12,7 @@ {#each things as thing} -

{thing}

- {:else} -
else
+

{thing}

+{:else} +
else
{/each} \ No newline at end of file diff --git a/test/runtime/samples/transition-js-each-else-block-outro/_config.js b/test/runtime/samples/transition-js-each-else-block-outro/_config.js index 11b1b387c0..863753b34a 100644 --- a/test/runtime/samples/transition-js-each-else-block-outro/_config.js +++ b/test/runtime/samples/transition-js-each-else-block-outro/_config.js @@ -1,20 +1,20 @@ export default { - props: { - things: [] - }, - test({ assert, component, target, window, raf }) { - const div = target.querySelector('div'); - component.things = ['a', 'b', 'c']; + props: { + things: [] + }, + test({ assert, component, target, window, raf }) { + const div = target.querySelector('div'); + component.things = ['a', 'b', 'c']; - raf.tick(200); - assert.equal(div.foo, 0.5); + raf.tick(200); + assert.equal(div.foo, 0.5); - raf.tick(300); - assert.equal(div.foo, 0.25); + raf.tick(300); + assert.equal(div.foo, 0.25); - raf.tick(400); - assert.equal(div.foo, 0); + raf.tick(400); + assert.equal(div.foo, 0); - raf.tick(500); - } + raf.tick(500); + } }; \ No newline at end of file diff --git a/test/runtime/samples/transition-js-each-else-block-outro/main.svelte b/test/runtime/samples/transition-js-each-else-block-outro/main.svelte index 72e91bb016..246c146127 100644 --- a/test/runtime/samples/transition-js-each-else-block-outro/main.svelte +++ b/test/runtime/samples/transition-js-each-else-block-outro/main.svelte @@ -12,7 +12,7 @@ {#each things as thing} -

{thing}

+

{thing}

{:else} -
else
+
else
{/each} \ No newline at end of file