mirror of
https://github.com/sveltejs/svelte.git
synced 2024-12-01 17:30:59 +01:00
sparse array patterns
This commit is contained in:
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…
Reference in New Issue
Block a user