Skip to content

Commit

Permalink
Merge pull request #668 from sveltejs/gh-667
Browse files Browse the repository at this point in the history
pass params to get_block
  • Loading branch information
Rich-Harris authored Jun 23, 2017
2 parents 096a2fb + f24db0b commit 73715b2
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/generators/dom/visitors/IfBlock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ function compoundWithOutros(
if (dynamic) {
block.builders.update.addBlock(deindent`
var ${previous_block_index} = ${current_block_index};
${current_block_index} = ${get_block}( state );
${current_block_index} = ${get_block}( ${params} );
if ( ${current_block_index} === ${previous_block_index} ) {
${if_current_block_index}${if_blocks}[ ${current_block_index} ].update( changed, ${params} );
} else {
Expand All @@ -405,7 +405,7 @@ function compoundWithOutros(
} else {
block.builders.update.addBlock(deindent`
var ${previous_block_index} = ${current_block_index};
${current_block_index} = ${get_block}( state );
${current_block_index} = ${get_block}( ${params} );
if ( ${current_block_index} !== ${previous_block_index} ) {
${changeBlock}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
export default {
data: {
foo: false,
threshold: 5
},

html: `
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
<div>5</div>
`,

test ( assert, component, target, window, raf ) {
const divs = target.querySelectorAll('div');

raf.tick(100);

component.set({ threshold: 4 });

raf.tick( 200 );
assert.htmlEqual(target.innerHTML, `
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
`);

component.destroy();
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{{#each [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] as number}}
{{#if foo}}
{{#if threshold >= number}}
<div transition:foo>{{number}}</div>
{{/if}}
{{else}}
{{#if threshold >= number}}
<div transition:foo>{{number}}</div>
{{/if}}
{{/if}}
{{/each}}

<script>
export default {
transitions: {
foo: function ( node ) {
return {
duration: 100,
tick: t => {
node.foo = t;
}
};
}
}
};
</script>

0 comments on commit 73715b2

Please sign in to comment.