use correct dependencies for each-block updates

pull/491/head
Rich-Harris 8 years ago
parent 9f2a20763a
commit 0c013cfd9b

@ -188,7 +188,7 @@ function unkeyed ( generator, block, state, node, snippet, { create_each_block,
` ); ` );
const dependencies = block.findDependencies( node.expression ); const dependencies = block.findDependencies( node.expression );
const allDependencies = new Set( block.dependencies ); const allDependencies = new Set( node._block.dependencies );
dependencies.forEach( dependency => { dependencies.forEach( dependency => {
allDependencies.add( dependency ); allDependencies.add( dependency );
}); });

@ -9,6 +9,12 @@ function create_main_fragment ( root, component ) {
each_block_iterations[i] = create_each_block( root, each_block_value, each_block_value[i], i, component ); each_block_iterations[i] = create_each_block( root, each_block_value, each_block_value[i], i, component );
} }
var text = createText( "\n\n" );
var p = createElement( 'p' );
var text_1_value = root.foo;
var text_1 = createText( text_1_value );
appendNode( text_1, p );
return { return {
mount: function ( target, anchor ) { mount: function ( target, anchor ) {
insertNode( each_block_anchor, target, anchor ); insertNode( each_block_anchor, target, anchor );
@ -16,6 +22,9 @@ function create_main_fragment ( root, component ) {
for ( var i = 0; i < each_block_iterations.length; i += 1 ) { for ( var i = 0; i < each_block_iterations.length; i += 1 ) {
each_block_iterations[i].mount( target, each_block_anchor ); each_block_iterations[i].mount( target, each_block_anchor );
} }
insertNode( text, target, anchor );
insertNode( p, target, anchor );
}, },
update: function ( changed, root ) { update: function ( changed, root ) {
@ -35,6 +44,10 @@ function create_main_fragment ( root, component ) {
each_block_iterations.length = each_block_value.length; each_block_iterations.length = each_block_value.length;
} }
if ( text_1_value !== ( text_1_value = root.foo ) ) {
text_1.data = text_1_value;
}
}, },
destroy: function ( detach ) { destroy: function ( detach ) {
@ -42,6 +55,8 @@ function create_main_fragment ( root, component ) {
if ( detach ) { if ( detach ) {
detachNode( each_block_anchor ); detachNode( each_block_anchor );
detachNode( text );
detachNode( p );
} }
} }
}; };

@ -6,4 +6,6 @@
{{{comment.html}}} {{{comment.html}}}
</div> </div>
{{/each}} {{/each}}
<p>{{foo}}</p>
Loading…
Cancel
Save