Merge pull request #897 from jacobmischka/destructure-each-updates

Destructure each updates
pull/902/head
Rich Harris 7 years ago committed by GitHub
commit b1e1c5c9bf

@ -229,12 +229,6 @@ const preprocessors = {
const contexts = new Map(block.contexts);
contexts.set(node.context, context);
if (node.destructuredContexts) {
for (const i = 0; i < node.destructuredContexts.length; i++) {
contexts.set(node.destructuredContexts[i], `${context}[${i}]`);
}
}
const indexes = new Map(block.indexes);
if (node.index) indexes.set(node.index, node.context);
@ -244,6 +238,13 @@ const preprocessors = {
const contextDependencies = new Map(block.contextDependencies);
contextDependencies.set(node.context, dependencies);
if (node.destructuredContexts) {
for (const i = 0; i < node.destructuredContexts.length; i++) {
contexts.set(node.destructuredContexts[i], `${context}[${i}]`);
contextDependencies.set(node.destructuredContexts[i], dependencies);
}
}
node._block = block.child({
comment: createDebuggingComment(node, generator),
name: generator.getUniqueName('create_each_block'),

@ -18,18 +18,19 @@ export default function visitEachBlock(
const contexts = new Map(block.contexts);
contexts.set(node.context, node.context);
if (node.destructuredContexts) {
for (const i = 0; i < node.destructuredContexts.length; i++) {
contexts.set(node.destructuredContexts[i], `${node.context}[${i}]`);
}
}
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 (const i = 0; i < node.destructuredContexts.length; i++) {
contexts.set(node.destructuredContexts[i], `${node.context}[${i}]`);
contextDependencies.set(node.destructuredContexts[i], dependencies);
}
}
const childBlock = block.child({
contexts,
indexes,

@ -9,5 +9,12 @@ export default {
html: `
<p>raccoon: hands</p>
<p>eagle: wings</p>
`
`,
test ( assert, component, target ) {
component.set({ animalPawsEntries: [['foo', 'bar']] });
assert.htmlEqual( target.innerHTML, `
<p>foo: bar</p>
`);
},
};

Loading…
Cancel
Save