mirror of
https://github.com/sveltejs/svelte.git
synced 2024-11-29 08:32:05 +01:00
fix: Make sure 'func' doesn't clash with destructured contexts (#8840)
Fixes: #8753
This commit is contained in:
parent
c0d92628dd
commit
3576c7443e
5
.changeset/eight-emus-allow.md
Normal file
5
.changeset/eight-emus-allow.md
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: ensure identifiers in destructuring contexts don't clash with existing ones
|
@ -36,6 +36,7 @@ export function unpack_destructuring({
|
||||
if (in_rest_element) {
|
||||
context_rest_properties.set(node.name, node);
|
||||
}
|
||||
component.used_names.add(node.name);
|
||||
} else if (node.type === 'ArrayPattern') {
|
||||
node.elements.forEach((element, i) => {
|
||||
if (!element) {
|
||||
|
@ -0,0 +1,25 @@
|
||||
export default {
|
||||
get props() {
|
||||
return {
|
||||
thePromise: new Promise((_) => {})
|
||||
};
|
||||
},
|
||||
|
||||
html: `
|
||||
Waiting...
|
||||
`,
|
||||
|
||||
async test({ assert, component, target }) {
|
||||
await (component.thePromise = Promise.resolve({ func: 12345 }));
|
||||
|
||||
assert.htmlEqual(target.innerHTML, '12345');
|
||||
|
||||
try {
|
||||
await (component.thePromise = Promise.reject({ func: 67890 }));
|
||||
} catch (e) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
assert.htmlEqual(target.innerHTML, '67890');
|
||||
}
|
||||
};
|
@ -0,0 +1,11 @@
|
||||
<script>
|
||||
export let thePromise;
|
||||
</script>
|
||||
|
||||
{#await thePromise}
|
||||
Waiting...
|
||||
{:then { func }}
|
||||
{(() => func)()}
|
||||
{:catch { func: func_1 }}
|
||||
{(() => func_1)()}
|
||||
{/await}
|
@ -0,0 +1,5 @@
|
||||
export default {
|
||||
html: `
|
||||
[12,13,14]
|
||||
`
|
||||
};
|
@ -0,0 +1,8 @@
|
||||
<script>
|
||||
const func = 100;
|
||||
</script>
|
||||
|
||||
{#if true}
|
||||
{@const [func_1] = [[12, 13, 14]]}
|
||||
{(() => JSON.stringify(func_1))()}
|
||||
{/if}
|
@ -0,0 +1,9 @@
|
||||
export default {
|
||||
html: `
|
||||
<p>1</p>
|
||||
<p>2</p>
|
||||
<p>3</p>
|
||||
<p>4</p>
|
||||
<p>5</p>
|
||||
`
|
||||
};
|
@ -0,0 +1,3 @@
|
||||
{#each [1, 2, 3, 4, 5] as func}
|
||||
<p>{(() => func)()}</p>
|
||||
{/each}
|
Loading…
Reference in New Issue
Block a user