pull/1243/head
Rich Harris 7 years ago
parent ce607d5ab3
commit f2ab5545dc

@ -19,8 +19,6 @@ export interface BlockOptions {
changeableIndexes?: Map<string, boolean>;
indexNames?: Map<string, string>;
listNames?: Map<string, string>;
indexName?: string;
listName?: string;
dependencies?: Set<string>;
}
@ -42,8 +40,6 @@ export default class Block {
dependencies: Set<string>;
indexNames: Map<string, string>;
listNames: Map<string, string>;
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(),

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

Loading…
Cancel
Save