diff --git a/src/compile/nodes/EachBlock.ts b/src/compile/nodes/EachBlock.ts index 35376c9e2b..d9c93fc036 100644 --- a/src/compile/nodes/EachBlock.ts +++ b/src/compile/nodes/EachBlock.ts @@ -40,16 +40,16 @@ export default class EachBlock extends Node { this.scope.add(context.key.name, this.expression.dependencies); }); + this.key = info.key + ? new Expression(compiler, this, this.scope, info.key) + : null; + if (this.index) { // index can only change if this is a keyed each block const dependencies = this.key ? this.expression.dependencies : []; this.scope.add(this.index, dependencies); } - this.key = info.key - ? new Expression(compiler, this, this.scope, info.key) - : null; - this.children = mapChildren(compiler, this, this.scope, info.children); this.else = info.else