sparse array patterns

pull/1385/head
Rich Harris 7 years ago
parent ffe91846f0
commit 9607593705

@ -46,8 +46,13 @@ export default function readContext(parser: Parser) {
do {
parser.allowWhitespace();
context.elements.push(readContext(parser));
parser.allowWhitespace();
if (parser.template[parser.index] === ',') {
context.elements.push(null);
} else {
context.elements.push(readContext(parser));
parser.allowWhitespace();
}
} while (parser.eat(','));
errorOnAssignmentPattern(parser);

@ -3,6 +3,8 @@ export default function unpackDestructuring(
node: Node,
tail: string
) {
if (!node) return;
if (node.type === 'Identifier') {
contexts.push({
key: node,

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

@ -0,0 +1,3 @@
{#each animalPawsEntries as [, pawType]}
<p>{pawType}</p>
{/each}
Loading…
Cancel
Save