all tests passing

pull/1173/head
Rich Harris 7 years ago
parent 71f2c350ec
commit 7baba8bf8c

@ -114,12 +114,7 @@ export default class Block {
this.aliases = new Map();
this.variables = new Map();
// this.getUniqueName = this.generator.getUniqueNameMaker([]); // TODO this is wrong... we probably don't need this any more
const getUniqueName = this.generator.getUniqueNameMaker([]); // TODO this is wrong... we probably don't need this any more
this.getUniqueName = name => {
return getUniqueName(name);
}
this.getUniqueName = this.generator.getUniqueNameMaker([]); // TODO this is wrong... we probably don't need this any more
this.hasUpdateMethod = false; // determined later
}

@ -69,7 +69,8 @@ export default class EachBlock extends Node {
if (this.destructuredContexts) {
for (let i = 0; i < this.destructuredContexts.length; i += 1) {
this.block.contexts.set(this.destructuredContexts[i], `${context}[${i}]`);
const context = this.block.getUniqueName(this.destructuredContexts[i]);
this.block.contexts.set(this.destructuredContexts[i], context);
}
}
@ -78,12 +79,11 @@ export default class EachBlock extends Node {
`${this.block.indexName}: #i`
];
// if (this.destructuredContexts) {
// for (let i = 0; i < this.destructuredContexts.length; i += 1) {
// contexts.set(this.destructuredContexts[i], `${context}[${i}]`);
// this.contextProps.push(`${this.destructuredContexts[i]}: ${this.block.listName}[#i][${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.generator.blocks.push(this.block);
this.initChildren(this.block, stripWhitespace, nextSibling);

@ -11,9 +11,7 @@ export default function visitEachBlock(
block.contextualise(node.expression);
const { dependencies, snippet } = node.metadata;
const context = node.destructuredContexts ? `[${node.destructuredContexts.join(', ')}]` : node.context;
const open = `\${ ${node.else ? `${snippet}.length ? ` : ''}${snippet}.map(${node.index ? `(${context}, ${node.index})` : `(${context})`} => \``;
const open = `\${ ${node.else ? `${snippet}.length ? ` : ''}${snippet}.map(${node.index ? `(${node.context}, ${node.index})` : `(${node.context})`} => \``;
generator.append(open);
// TODO should this be the generator's job? It's duplicated between

@ -284,7 +284,7 @@ function create_main_fragment(component, state) {
// (1:0) {{#each comments as comment, i}}
function create_each_block(component, state) {
var comment = state.comment;
var comment = state.comment, i = state.i;
var div, strong, text, text_1, span, text_2_value = comment.author, text_2, text_3, text_4_value = state.elapsed(comment.time, state.time), text_4, text_5, text_6, raw_value = comment.html, raw_before;
return {
@ -325,6 +325,7 @@ function create_each_block(component, state) {
p: function update(changed, state) {
comment = state.comment;
i = state.i;
if ((changed.comments) && text_2_value !== (text_2_value = comment.author)) {
text_2.data = text_2_value;
}

@ -84,7 +84,7 @@ function create_main_fragment(component, state) {
// (1:0) {{#each comments as comment, i}}
function create_each_block(component, state) {
var comment = state.comment;
var comment = state.comment, i = state.i;
var div, strong, text, text_1, span, text_2_value = comment.author, text_2, text_3, text_4_value = state.elapsed(comment.time, state.time), text_4, text_5, text_6, raw_value = comment.html, raw_before;
return {
@ -125,6 +125,7 @@ function create_each_block(component, state) {
p: function update(changed, state) {
comment = state.comment;
i = state.i;
if ((changed.comments) && text_2_value !== (text_2_value = comment.author)) {
text_2.data = text_2_value;
}

Loading…
Cancel
Save