mirror of https://github.com/sveltejs/svelte
set context in await blocks - fixes #2443
parent
860040a7fa
commit
0f65b6cc9d
@ -0,0 +1,6 @@
|
||||
<script>
|
||||
import { getContext } from 'svelte';
|
||||
const num = getContext('test');
|
||||
</script>
|
||||
|
||||
<p>Context value: {num}</p>
|
@ -0,0 +1,13 @@
|
||||
export default {
|
||||
html: `
|
||||
<p>...waiting</p>
|
||||
`,
|
||||
|
||||
async test({ assert, component, target }) {
|
||||
await component.promise;
|
||||
|
||||
assert.htmlEqual(target.innerHTML, `
|
||||
<p>Context value: 123</p>
|
||||
`);
|
||||
}
|
||||
};
|
@ -0,0 +1,14 @@
|
||||
<script>
|
||||
import { setContext } from 'svelte';
|
||||
import Child from './Child.svelte';
|
||||
|
||||
setContext('test', 123);
|
||||
|
||||
export let promise = Promise.resolve();
|
||||
</script>
|
||||
|
||||
{#await promise}
|
||||
<p>...waiting</p>
|
||||
{:then}
|
||||
<Child />
|
||||
{/await}
|
Loading…
Reference in new issue