mirror of
https://github.com/kevin-DL/sapper.git
synced 2026-01-11 19:04:30 +00:00
Merge pull request #608 from cudr/preload_return_fix
Don't crash if preload return empty
This commit is contained in:
@@ -225,7 +225,7 @@ export function get_page_handler(
|
||||
|
||||
props[`level${l++}`] = {
|
||||
component: part.component,
|
||||
props: preloaded[i + 1],
|
||||
props: preloaded[i + 1] || {},
|
||||
segment: segments[i]
|
||||
};
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
<script context="module">
|
||||
export function preload() {}
|
||||
</script>
|
||||
|
||||
<h1>Page loaded</h1>
|
||||
@@ -37,6 +37,15 @@ describe('preloading', function() {
|
||||
assert.equal(await title(), 'true');
|
||||
});
|
||||
|
||||
it('prevent crash if preload return nothing', async () => {
|
||||
await page.goto(`${base}/preload-nothing`);
|
||||
|
||||
await start();
|
||||
await wait(50);
|
||||
|
||||
assert.equal(await title(), 'Page loaded');
|
||||
});
|
||||
|
||||
it('bails on custom classes returned from preload', async () => {
|
||||
await page.goto(`${base}/preload-values/custom-class`);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user