Merge pull request #608 from cudr/preload_return_fix

Don't crash if preload return empty
This commit is contained in:
Rich Harris
2019-04-27 11:15:14 -04:00
committed by GitHub
3 changed files with 15 additions and 1 deletions

View File

@@ -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]
};
}

View File

@@ -0,0 +1,5 @@
<script context="module">
export function preload() {}
</script>
<h1>Page loaded</h1>

View File

@@ -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`);