From 41c214a9860fc815c5239a69e97c5a8c82c292be Mon Sep 17 00:00:00 2001 From: Hunter Perrin Date: Wed, 31 May 2017 18:58:30 -0700 Subject: [PATCH] Fixed each block producing elements in wrong order after change. Fixes #610. --- src/generators/dom/visitors/EachBlock.ts | 4 ++-- test/js/samples/each-block-changed-check/_actual-bundle.js | 2 +- test/js/samples/each-block-changed-check/expected-bundle.js | 2 +- test/js/samples/each-block-changed-check/expected.js | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/generators/dom/visitors/EachBlock.ts b/src/generators/dom/visitors/EachBlock.ts index 212f1af8b3..39657aff4d 100644 --- a/src/generators/dom/visitors/EachBlock.ts +++ b/src/generators/dom/visitors/EachBlock.ts @@ -139,7 +139,7 @@ function keyed ( generator: DomGenerator, block: Block, state: State, node: Node block.builders.mount.addBlock( deindent` var ${iteration} = ${head}; while ( ${iteration} ) { - ${iteration}.${mountOrIntro}( ${block.target}, null ); + ${iteration}.${mountOrIntro}( ${block.target}, anchor ); ${iteration} = ${iteration}.next; } ` ); @@ -284,7 +284,7 @@ function unkeyed ( generator: DomGenerator, block: Block, state: State, node: No if ( !state.parentNode ) { block.builders.mount.addBlock( deindent` for ( var ${i} = 0; ${i} < ${iterations}.length; ${i} += 1 ) { - ${iterations}[${i}].${mountOrIntro}( ${block.target}, null ); + ${iterations}[${i}].${mountOrIntro}( ${block.target}, anchor ); } ` ); } diff --git a/test/js/samples/each-block-changed-check/_actual-bundle.js b/test/js/samples/each-block-changed-check/_actual-bundle.js index 95a876bad5..759b1ef75b 100644 --- a/test/js/samples/each-block-changed-check/_actual-bundle.js +++ b/test/js/samples/each-block-changed-check/_actual-bundle.js @@ -153,7 +153,7 @@ function create_main_fragment ( state, component ) { return { mount: function ( target, anchor ) { for ( var i = 0; i < each_block_iterations.length; i += 1 ) { - each_block_iterations[i].mount( target, null ); + each_block_iterations[i].mount( target, anchor ); } insertNode( text, target, anchor ); diff --git a/test/js/samples/each-block-changed-check/expected-bundle.js b/test/js/samples/each-block-changed-check/expected-bundle.js index 95a876bad5..759b1ef75b 100644 --- a/test/js/samples/each-block-changed-check/expected-bundle.js +++ b/test/js/samples/each-block-changed-check/expected-bundle.js @@ -153,7 +153,7 @@ function create_main_fragment ( state, component ) { return { mount: function ( target, anchor ) { for ( var i = 0; i < each_block_iterations.length; i += 1 ) { - each_block_iterations[i].mount( target, null ); + each_block_iterations[i].mount( target, anchor ); } insertNode( text, target, anchor ); diff --git a/test/js/samples/each-block-changed-check/expected.js b/test/js/samples/each-block-changed-check/expected.js index 128d332196..96624d88db 100644 --- a/test/js/samples/each-block-changed-check/expected.js +++ b/test/js/samples/each-block-changed-check/expected.js @@ -19,7 +19,7 @@ function create_main_fragment ( state, component ) { return { mount: function ( target, anchor ) { for ( var i = 0; i < each_block_iterations.length; i += 1 ) { - each_block_iterations[i].mount( target, null ); + each_block_iterations[i].mount( target, anchor ); } insertNode( text, target, anchor ); @@ -160,4 +160,4 @@ SvelteComponent.prototype.teardown = SvelteComponent.prototype.destroy = functio this._torndown = true; }; -export default SvelteComponent; \ No newline at end of file +export default SvelteComponent;