From 12c7d1c86d2ba813b5fcfac3a1480473af198109 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Thu, 15 Mar 2018 14:04:52 -0400 Subject: [PATCH] flawed solution to #1240 --- src/generators/dom/Block.ts | 3 --- src/generators/nodes/EachBlock.ts | 14 +++++--------- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/src/generators/dom/Block.ts b/src/generators/dom/Block.ts index d101287532c4..48e205f64c05 100644 --- a/src/generators/dom/Block.ts +++ b/src/generators/dom/Block.ts @@ -44,7 +44,6 @@ export default class Block { listNames: Map; indexName: string; listName: string; - listAlias: string; builders: { init: CodeBuilder; @@ -121,8 +120,6 @@ export default class Block { .set('state', this.getUniqueName('state')); if (this.key) this.aliases.set('key', this.getUniqueName('key')); - this.listAlias = this.getUniqueName(this.listName); - this.hasUpdateMethod = false; // determined later } diff --git a/src/generators/nodes/EachBlock.ts b/src/generators/nodes/EachBlock.ts index 1864f9695831..b2ac0b403fba 100644 --- a/src/generators/nodes/EachBlock.ts +++ b/src/generators/nodes/EachBlock.ts @@ -45,11 +45,7 @@ export default class EachBlock extends Node { indexes: new Map(block.indexes), changeableIndexes: new Map(block.changeableIndexes), - listName: ( - (this.expression.type === 'MemberExpression' && !this.expression.computed) ? this.expression.property.name : - this.expression.type === 'Identifier' ? this.expression.name : - `each_value` - ), + listName: this.generator.getUniqueName('each_value'), indexName: this.index || `${this.context}_index`, indexNames: new Map(block.indexNames), @@ -75,14 +71,14 @@ export default class EachBlock extends Node { } this.contextProps = [ - `${this.block.listName}: ${this.block.listAlias}`, - `${this.context}: ${this.block.listAlias}[#i]`, + `${this.block.listName}: ${this.block.listName}`, + `${this.context}: ${this.block.listName}[#i]`, `${this.block.indexName}: #i` ]; if (this.destructuredContexts) { for (let i = 0; i < this.destructuredContexts.length; i += 1) { - this.contextProps.push(`${this.destructuredContexts[i]}: ${this.block.listAlias}[#i][${i}]`); + this.contextProps.push(`${this.destructuredContexts[i]}: ${this.block.listName}[#i][${i}]`); } } @@ -117,7 +113,7 @@ export default class EachBlock extends Node { const each = this.var; const create_each_block = this.block.name; - const each_block_value = this.block.listAlias; + const each_block_value = this.block.listName; const iterations = this.iterations; const needsAnchor = this.next ? !this.next.isDomNode() : !parentNode || !this.parent.isDomNode();