Skip to content

Commit

Permalink
Merge branch 'master' into gh-1316
Browse files Browse the repository at this point in the history
  • Loading branch information
Rich-Harris committed Apr 22, 2018
2 parents d3afc4c + 83e62ea commit 6484333
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 13 deletions.
1 change: 0 additions & 1 deletion src/generators/server-side-rendering/Block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export default class Block {

contexts: Map<string, string>;
indexes: Map<string, string>;
contextDependencies: Map<string, string[]>;

constructor(options: BlockOptions) {
Object.assign(this, options);
Expand Down
6 changes: 1 addition & 5 deletions src/generators/server-side-rendering/visitors/AwaitBlock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,14 @@ export default function visitAwaitBlock(
node: Node
) {
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
// here and the equivalent DOM compiler visitor
const contexts = new Map(block.contexts);
contexts.set(node.value, '__value');

const contextDependencies = new Map(block.contextDependencies);
contextDependencies.set(node.value, dependencies);

const childBlock = block.child({
contextDependencies,
contexts
});

Expand Down
9 changes: 2 additions & 7 deletions src/generators/server-side-rendering/visitors/EachBlock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default function visitEachBlock(
node: Node
) {
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})`} => \``;
generator.append(open);
Expand All @@ -22,20 +22,15 @@ export default function visitEachBlock(
const indexes = new Map(block.indexes);
if (node.index) indexes.set(node.index, node.context);

const contextDependencies = new Map(block.contextDependencies);
contextDependencies.set(node.context, dependencies);

if (node.destructuredContexts) {
for (let i = 0; i < node.destructuredContexts.length; i += 1) {
contexts.set(node.destructuredContexts[i], `${node.context}[${i}]`);
contextDependencies.set(node.destructuredContexts[i], dependencies);
}
}

const childBlock = block.child({
contexts,
indexes,
contextDependencies,
indexes
});

node.children.forEach((child: Node) => {
Expand Down

0 comments on commit 6484333

Please sign in to comment.