From f94df9fb6da3618c4de490aafbc4dc486efa59af Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Tue, 6 Dec 2016 11:16:00 -0500 Subject: [PATCH] avoid empty `if ()` condition when updating each blocks with indices --- compiler/generate/visitors/Component.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/compiler/generate/visitors/Component.js b/compiler/generate/visitors/Component.js index 7fcb427b41..b56e221878 100644 --- a/compiler/generate/visitors/Component.js +++ b/compiler/generate/visitors/Component.js @@ -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`