Skip to content

Commit

Permalink
flawed solution to #1240
Browse files Browse the repository at this point in the history
  • Loading branch information
Rich-Harris committed Mar 15, 2018
1 parent 6f65554 commit 12c7d1c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
3 changes: 0 additions & 3 deletions src/generators/dom/Block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ export default class Block {
listNames: Map<string, string>;
indexName: string;
listName: string;
listAlias: string;

builders: {
init: CodeBuilder;
Expand Down Expand Up @@ -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
}

Expand Down
14 changes: 5 additions & 9 deletions src/generators/nodes/EachBlock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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}]`);
}
}

Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 12c7d1c

Please sign in to comment.