mirror of
https://github.com/kevin-DL/sapper.git
synced 2026-01-12 03:05:12 +00:00
more tidying up
This commit is contained in:
@@ -115,7 +115,6 @@ export function scroll_state() {
|
||||
}
|
||||
|
||||
export async function navigate(target: Target, id: number, noscroll?: boolean, hash?: string): Promise<any> {
|
||||
let scroll: ScrollPosition;
|
||||
if (id) {
|
||||
// popstate or initial navigation
|
||||
cid = id;
|
||||
@@ -143,18 +142,16 @@ export async function navigate(target: Target, id: number, noscroll?: boolean, h
|
||||
prefetching = null;
|
||||
|
||||
const token = current_token = {};
|
||||
|
||||
const { redirect, page, props, branch } = await loaded;
|
||||
if (token !== current_token) return; // a secondary navigation happened while we were loading
|
||||
|
||||
if (redirect) return goto(redirect.location, { replaceState: true });
|
||||
|
||||
await render(branch, props, page, scroll_history[id], noscroll, hash, token);
|
||||
await render(branch, props, page, scroll_history[id], noscroll, hash);
|
||||
if (document.activeElement) document.activeElement.blur();
|
||||
}
|
||||
|
||||
async function render(branch: any[], props: any, page: Page, scroll: ScrollPosition, noscroll: boolean, hash: string, token: {}) {
|
||||
if (current_token !== token) return;
|
||||
|
||||
async function render(branch: any[], props: any, page: Page, scroll: ScrollPosition, noscroll: boolean, hash: string) {
|
||||
stores.page.set(page);
|
||||
stores.preloading.set(null);
|
||||
|
||||
@@ -269,15 +266,12 @@ export async function hydrate_target(target: Target): Promise<{
|
||||
|
||||
if (redirect) return { redirect };
|
||||
|
||||
const page_data = {
|
||||
path,
|
||||
query,
|
||||
params
|
||||
};
|
||||
const page = { path, query, params };
|
||||
|
||||
if (error) {
|
||||
// TODO be nice if this was less of a special case
|
||||
return {
|
||||
page: page_data,
|
||||
page,
|
||||
props: {
|
||||
child: {
|
||||
component: ErrorComponent,
|
||||
@@ -304,7 +298,7 @@ export async function hydrate_target(target: Target): Promise<{
|
||||
level = level.props.child;
|
||||
});
|
||||
|
||||
return { props, page: page_data, branch };
|
||||
return { props, page, branch };
|
||||
}
|
||||
|
||||
function load_css(chunk: string) {
|
||||
|
||||
Reference in New Issue
Block a user