exclude indexes from dependencies

pull/491/head
Rich-Harris 9 years ago
parent 0c013cfd9b
commit 3629c9e9a1

@ -151,7 +151,7 @@ export default class Generator {
}; };
} }
findDependencies ( contextDependencies, expression ) { findDependencies ( contextDependencies, indexes, expression ) {
if ( expression._dependencies ) return expression._dependencies; if ( expression._dependencies ) return expression._dependencies;
let scope = annotateWithScopes( expression ); let scope = annotateWithScopes( expression );
@ -170,7 +170,7 @@ export default class Generator {
if ( contextDependencies.has( name ) ) { if ( contextDependencies.has( name ) ) {
dependencies.push( ...contextDependencies.get( name ) ); dependencies.push( ...contextDependencies.get( name ) );
} else { } else if ( !indexes.has( name ) ) {
dependencies.push( name ); dependencies.push( name );
} }

@ -75,7 +75,7 @@ export default class Block {
} }
findDependencies ( expression ) { findDependencies ( expression ) {
return this.generator.findDependencies( this.contextDependencies, expression ); return this.generator.findDependencies( this.contextDependencies, this.indexes, expression );
} }
mount ( name, parentNode ) { mount ( name, parentNode ) {

@ -62,19 +62,25 @@ function create_main_fragment ( root, component ) {
}; };
} }
function create_each_block ( root, each_block_value, comment, comment_index, component ) { function create_each_block ( root, each_block_value, comment, i, component ) {
var div = createElement( 'div' ); var div = createElement( 'div' );
div.className = "comment"; div.className = "comment";
var strong = createElement( 'strong' );
appendNode( strong, div );
var text_value = i;
var text = createText( text_value );
appendNode( text, strong );
appendNode( createText( "\n\n\t\t" ), div );
var span = createElement( 'span' ); var span = createElement( 'span' );
appendNode( span, div ); appendNode( span, div );
span.className = "meta"; span.className = "meta";
var text_value = comment.author; var text_2_value = comment.author;
var text = createText( text_value );
appendNode( text, span );
appendNode( createText( " wrote " ), span );
var text_2_value = root.elapsed(comment.time, root.time);
var text_2 = createText( text_2_value ); var text_2 = createText( text_2_value );
appendNode( text_2, span ); appendNode( text_2, span );
appendNode( createText( " wrote " ), span );
var text_4_value = root.elapsed(comment.time, root.time);
var text_4 = createText( text_4_value );
appendNode( text_4, span );
appendNode( createText( " ago:" ), span ); appendNode( createText( " ago:" ), span );
appendNode( createText( "\n\n\t\t" ), div ); appendNode( createText( "\n\n\t\t" ), div );
var raw_before = createElement( 'noscript' ); var raw_before = createElement( 'noscript' );
@ -89,15 +95,19 @@ function create_each_block ( root, each_block_value, comment, comment_index, com
insertNode( div, target, anchor ); insertNode( div, target, anchor );
}, },
update: function ( changed, root, each_block_value, comment, comment_index ) { update: function ( changed, root, each_block_value, comment, i ) {
if ( text_value !== ( text_value = comment.author ) ) { if ( text_value !== ( text_value = i ) ) {
text.data = text_value; text.data = text_value;
} }
if ( text_2_value !== ( text_2_value = root.elapsed(comment.time, root.time) ) ) { if ( text_2_value !== ( text_2_value = comment.author ) ) {
text_2.data = text_2_value; text_2.data = text_2_value;
} }
if ( text_4_value !== ( text_4_value = root.elapsed(comment.time, root.time) ) ) {
text_4.data = text_4_value;
}
if ( raw_value !== ( raw_value = comment.html ) ) { if ( raw_value !== ( raw_value = comment.html ) ) {
detachBetween( raw_before, raw_after ); detachBetween( raw_before, raw_after );
raw_before.insertAdjacentHTML( 'afterend', raw_value ); raw_before.insertAdjacentHTML( 'afterend', raw_value );

@ -1,5 +1,7 @@
{{#each comments as comment}} {{#each comments as comment, i}}
<div class='comment'> <div class='comment'>
<strong>{{i}}</strong>
<span class='meta'> <span class='meta'>
{{comment.author}} wrote {{elapsed(comment.time, time)}} ago: {{comment.author}} wrote {{elapsed(comment.time, time)}} ago:
</span> </span>

Loading…
Cancel
Save