mirror of https://github.com/sveltejs/svelte
fix: better await block scope analysis (#10849)
The await block scope analysis was flawed because it did not set the scope for the value/error field before visiting those nodes, resulting in the wrong scopes getting references As a byproduct, this fixes #8141pull/10856/head
parent
efe85fcce0
commit
86c57f96de
@ -0,0 +1,12 @@
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
async test({ assert, target }) {
|
||||
await new Promise((r) => setTimeout(r, 200)); // wait for await block to resolve
|
||||
|
||||
const options = target.querySelectorAll('option');
|
||||
assert.ok(!options[0].selected);
|
||||
assert.ok(options[1].selected);
|
||||
assert.ok(!options[2].selected);
|
||||
}
|
||||
});
|
@ -0,0 +1,19 @@
|
||||
<script>
|
||||
let promise = getNumbers();
|
||||
let selected = 2;
|
||||
|
||||
async function getNumbers() {
|
||||
await new Promise(resolve => setTimeout(resolve, 100));
|
||||
return [1, 2, 3];
|
||||
}
|
||||
</script>
|
||||
|
||||
<select bind:value={selected}>
|
||||
{#await promise}
|
||||
<option>-1</option>
|
||||
{:then numbers}
|
||||
{#each numbers as number}
|
||||
<option>{number}</option>
|
||||
{/each}
|
||||
{/await}
|
||||
</select>
|
Loading…
Reference in new issue