Merge branch 'master' into gh-1316

pull/1367/head
Rich Harris 7 years ago
commit 64843331d4

@ -14,7 +14,6 @@ export default class Block {
contexts: Map<string, string>; contexts: Map<string, string>;
indexes: Map<string, string>; indexes: Map<string, string>;
contextDependencies: Map<string, string[]>;
constructor(options: BlockOptions) { constructor(options: BlockOptions) {
Object.assign(this, options); Object.assign(this, options);

@ -9,18 +9,14 @@ export default function visitAwaitBlock(
node: Node node: Node
) { ) {
block.contextualise(node.expression); block.contextualise(node.expression);
const { dependencies, snippet } = node.metadata; const { snippet } = node.metadata;
// TODO should this be the generator's job? It's duplicated between // TODO should this be the generator's job? It's duplicated between
// here and the equivalent DOM compiler visitor // here and the equivalent DOM compiler visitor
const contexts = new Map(block.contexts); const contexts = new Map(block.contexts);
contexts.set(node.value, '__value'); contexts.set(node.value, '__value');
const contextDependencies = new Map(block.contextDependencies);
contextDependencies.set(node.value, dependencies);
const childBlock = block.child({ const childBlock = block.child({
contextDependencies,
contexts contexts
}); });

@ -9,7 +9,7 @@ export default function visitEachBlock(
node: Node node: Node
) { ) {
block.contextualise(node.expression); block.contextualise(node.expression);
const { dependencies, snippet } = node.metadata; const { snippet } = node.metadata;
const open = `\${ ${node.else ? `${snippet}.length ? ` : ''}${snippet}.map(${node.index ? `(${node.context}, ${node.index})` : `(${node.context})`} => \``; const open = `\${ ${node.else ? `${snippet}.length ? ` : ''}${snippet}.map(${node.index ? `(${node.context}, ${node.index})` : `(${node.context})`} => \``;
generator.append(open); generator.append(open);
@ -22,20 +22,15 @@ export default function visitEachBlock(
const indexes = new Map(block.indexes); const indexes = new Map(block.indexes);
if (node.index) indexes.set(node.index, node.context); if (node.index) indexes.set(node.index, node.context);
const contextDependencies = new Map(block.contextDependencies);
contextDependencies.set(node.context, dependencies);
if (node.destructuredContexts) { if (node.destructuredContexts) {
for (let i = 0; i < node.destructuredContexts.length; i += 1) { for (let i = 0; i < node.destructuredContexts.length; i += 1) {
contexts.set(node.destructuredContexts[i], `${node.context}[${i}]`); contexts.set(node.destructuredContexts[i], `${node.context}[${i}]`);
contextDependencies.set(node.destructuredContexts[i], dependencies);
} }
} }
const childBlock = block.child({ const childBlock = block.child({
contexts, contexts,
indexes, indexes
contextDependencies,
}); });
node.children.forEach((child: Node) => { node.children.forEach((child: Node) => {

Loading…
Cancel
Save