mirror of https://github.com/sveltejs/svelte
This will get the tests in https://github.com/sveltejs/kit/pull/15308 green, right now they fail because page state cannot be found because context not availablepull/17799/head
parent
fef7e0f742
commit
d798dfee0d
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: set server context after async transformError
|
||||
@ -0,0 +1,16 @@
|
||||
import { tick } from 'svelte';
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
solo: true,
|
||||
mode: ['hydrate', 'async-server', 'client'],
|
||||
ssrHtml: '<p>caught: error (hello)</p>',
|
||||
transformError: () => {
|
||||
return Promise.resolve('error');
|
||||
},
|
||||
|
||||
async test({ assert, target }) {
|
||||
await tick();
|
||||
assert.htmlEqual(target.innerHTML, '<p>caught: error (hello)</p>');
|
||||
}
|
||||
});
|
||||
@ -0,0 +1,14 @@
|
||||
<script>
|
||||
import { get } from "./main.svelte";
|
||||
|
||||
let { error } = $props();
|
||||
const context = get()
|
||||
</script>
|
||||
|
||||
{#if error}
|
||||
<p>caught: {await error} ({context})</p>
|
||||
{:else}
|
||||
{(() => {
|
||||
throw 'catch me';
|
||||
})()}
|
||||
{/if}
|
||||
@ -0,0 +1,19 @@
|
||||
<script module>
|
||||
import { createContext } from "svelte";
|
||||
import Child from "./child.svelte";
|
||||
|
||||
const [ get, set ] = createContext();
|
||||
export {get};
|
||||
</script>
|
||||
|
||||
<script>
|
||||
set('hello');
|
||||
</script>
|
||||
|
||||
<svelte:boundary>
|
||||
{#snippet failed(error)}
|
||||
<Child {error} />
|
||||
{/snippet}
|
||||
|
||||
<Child />
|
||||
</svelte:boundary>
|
||||
Loading…
Reference in new issue