mirror of https://github.com/sveltejs/svelte
Merge pull request #3093 from sveltejs/gh-3092
handle member expressions in destructuring assignmentspull/3096/head
commit
2de0f1cbb1
@ -0,0 +1,23 @@
|
||||
export default {
|
||||
html: `
|
||||
<ul>
|
||||
<li>Gruyere</li>
|
||||
<li>Compté</li>
|
||||
<li>Beaufort</li>
|
||||
<li>Abondance</li>
|
||||
</ul>
|
||||
`,
|
||||
|
||||
async test({ assert, component, target }) {
|
||||
await component.swap(0, 1);
|
||||
|
||||
assert.htmlEqual(target.innerHTML, `
|
||||
<ul>
|
||||
<li>Compté</li>
|
||||
<li>Gruyere</li>
|
||||
<li>Beaufort</li>
|
||||
<li>Abondance</li>
|
||||
</ul>
|
||||
`);
|
||||
}
|
||||
};
|
@ -0,0 +1,18 @@
|
||||
<script>
|
||||
let cheese = [
|
||||
'Gruyere',
|
||||
'Compté',
|
||||
'Beaufort',
|
||||
'Abondance',
|
||||
];
|
||||
|
||||
export function swap(a, b) {
|
||||
[cheese[a], cheese[b]] = [cheese[b], cheese[a]];
|
||||
}
|
||||
</script>
|
||||
|
||||
<ul>
|
||||
{#each cheese as cheese}
|
||||
<li>{cheese}</li>
|
||||
{/each}
|
||||
</ul>
|
Loading…
Reference in new issue