mirror of
https://github.com/kevin-DL/sapper.git
synced 2026-01-19 22:05:20 +00:00
remove 4xx and 5xx pages when initing
This commit is contained in:
@@ -4,6 +4,7 @@ import { Component, ComponentConstructor, Params, Query, Route, RouteData, Scrol
|
|||||||
export let component: Component;
|
export let component: Component;
|
||||||
let target: Node;
|
let target: Node;
|
||||||
let routes: Route[];
|
let routes: Route[];
|
||||||
|
let errors: { '4xx': Route, '5xx': Route };
|
||||||
|
|
||||||
const history = typeof window !== 'undefined' ? window.history : {
|
const history = typeof window !== 'undefined' ? window.history : {
|
||||||
pushState: (state: any, title: string, href: string) => {},
|
pushState: (state: any, title: string, href: string) => {},
|
||||||
@@ -196,7 +197,11 @@ let inited: boolean;
|
|||||||
|
|
||||||
export function init(_target: Node, _routes: Route[]) {
|
export function init(_target: Node, _routes: Route[]) {
|
||||||
target = _target;
|
target = _target;
|
||||||
routes = _routes;
|
routes = _routes.filter(r => !r.error);
|
||||||
|
errors = {
|
||||||
|
'4xx': _routes.find(r => r.error === '4xx'),
|
||||||
|
'5xx': _routes.find(r => r.error === '5xx')
|
||||||
|
};
|
||||||
|
|
||||||
if (!inited) { // this check makes HMR possible
|
if (!inited) { // this check makes HMR possible
|
||||||
window.addEventListener('click', handle_click);
|
window.addEventListener('click', handle_click);
|
||||||
|
|||||||
Reference in New Issue
Block a user