diff --git a/src/generators/dom/Block.ts b/src/generators/dom/Block.ts index 9297a357db..2e03c45e75 100644 --- a/src/generators/dom/Block.ts +++ b/src/generators/dom/Block.ts @@ -19,8 +19,6 @@ export interface BlockOptions { changeableIndexes?: Map; indexNames?: Map; listNames?: Map; - indexName?: string; - listName?: string; dependencies?: Set; } @@ -42,8 +40,6 @@ export default class Block { dependencies: Set; indexNames: Map; listNames: Map; - indexName: string; - listName: string; builders: { init: CodeBuilder; @@ -91,9 +87,6 @@ export default class Block { this.indexNames = options.indexNames; this.listNames = options.listNames; - this.indexName = options.indexName; - this.listName = options.listName; - this.builders = { init: new CodeBuilder(), create: new CodeBuilder(), diff --git a/src/generators/nodes/EachBlock.ts b/src/generators/nodes/EachBlock.ts index b2ac0b403f..297f786172 100644 --- a/src/generators/nodes/EachBlock.ts +++ b/src/generators/nodes/EachBlock.ts @@ -45,16 +45,16 @@ export default class EachBlock extends Node { indexes: new Map(block.indexes), changeableIndexes: new Map(block.changeableIndexes), - listName: this.generator.getUniqueName('each_value'), - indexName: this.index || `${this.context}_index`, - indexNames: new Map(block.indexNames), listNames: new Map(block.listNames) }); + const listName = this.generator.getUniqueName('each_value'); + const indexName = this.index || this.generator.getUniqueName(`${this.context}_index`); + this.block.contextTypes.set(this.context, 'each'); - this.block.indexNames.set(this.context, this.block.indexName); - this.block.listNames.set(this.context, this.block.listName); + this.block.indexNames.set(this.context, indexName); + this.block.listNames.set(this.context, listName); if (this.index) { this.block.indexes.set(this.index, this.context); this.block.changeableIndexes.set(this.index, this.key) @@ -71,14 +71,14 @@ export default class EachBlock extends Node { } this.contextProps = [ - `${this.block.listName}: ${this.block.listName}`, - `${this.context}: ${this.block.listName}[#i]`, - `${this.block.indexName}: #i` + `${listName}: ${listName}`, + `${this.context}: ${listName}[#i]`, + `${indexName}: #i` ]; if (this.destructuredContexts) { for (let i = 0; i < this.destructuredContexts.length; i += 1) { - this.contextProps.push(`${this.destructuredContexts[i]}: ${this.block.listName}[#i][${i}]`); + this.contextProps.push(`${this.destructuredContexts[i]}: ${listName}[#i][${i}]`); } } @@ -113,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.listName; + const each_block_value = this.block.listNames.get(this.context); const iterations = this.iterations; const needsAnchor = this.next ? !this.next.isDomNode() : !parentNode || !this.parent.isDomNode();