Skip to content

Commit

Permalink
avoid empty if () condition when updating each blocks with indices
Browse files Browse the repository at this point in the history
  • Loading branch information
Rich-Harris committed Dec 6, 2016
1 parent 53c6b87 commit f94df9f
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions compiler/generate/visitors/Component.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,15 @@ export default {

if ( local.dynamicAttributes.length ) {
const updates = local.dynamicAttributes.map( attribute => {
return deindent`
if ( ${attribute.dependencies.map( dependency => `'${dependency}' in changed` ).join( '||' )} ) ${name}_changes.${attribute.name} = ${attribute.value};
`;
if ( attribute.dependencies.length ) {
return deindent`
if ( ${attribute.dependencies.map( dependency => `'${dependency}' in changed` ).join( '||' )} ) ${name}_changes.${attribute.name} = ${attribute.value};
`;
}

// TODO this is an odd situation to encounter – I *think* it should only happen with
// each block indices, in which case it may be possible to optimise this
return `${name}_changes.${attribute.name} = ${attribute.value};`;
});

local.update.push( deindent`
Expand Down

0 comments on commit f94df9f

Please sign in to comment.