Skip to content

Commit a795335

Browse files
committed
remove router enable/disable as well
1 parent 111fb9b commit a795335

File tree

1 file changed

+31
-50
lines changed

1 file changed

+31
-50
lines changed

packages/kit/src/runtime/client/router.js

Lines changed: 31 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@ export class Router {
4949
this.renderer = renderer;
5050
renderer.router = this;
5151

52-
this.enabled = true;
53-
5452
// make it possible to reset focus
5553
document.body.setAttribute('tabindex', '-1');
5654

@@ -152,8 +150,6 @@ export class Router {
152150

153151
/** @param {MouseEvent} event */
154152
addEventListener('click', (event) => {
155-
if (!this.enabled) return;
156-
157153
// Adapted from https://github.com/visionmedia/page.js
158154
// MIT license https://github.com/visionmedia/page.js#license
159155
if (event.button || event.which !== 1) return;
@@ -211,26 +207,26 @@ export class Router {
211207
});
212208

213209
addEventListener('popstate', (event) => {
214-
if (event.state && this.enabled) {
215-
// if a popstate-driven navigation is cancelled, we need to counteract it
216-
// with history.go, which means we end up back here, hence this check
217-
if (event.state['sveltekit:index'] === this.current_history_index) return;
218-
219-
this._navigate({
220-
url: new URL(location.href),
221-
scroll: event.state['sveltekit:scroll'],
222-
keepfocus: false,
223-
chain: [],
224-
details: null,
225-
accepted: () => {
226-
this.current_history_index = event.state['sveltekit:index'];
227-
},
228-
blocked: () => {
229-
const delta = this.current_history_index - event.state['sveltekit:index'];
230-
history.go(delta);
231-
}
232-
});
233-
}
210+
if (!event.state) return;
211+
212+
// if a popstate-driven navigation is cancelled, we need to counteract it
213+
// with history.go, which means we end up back here, hence this check
214+
if (event.state['sveltekit:index'] === this.current_history_index) return;
215+
216+
this._navigate({
217+
url: new URL(location.href),
218+
scroll: event.state['sveltekit:scroll'],
219+
keepfocus: false,
220+
chain: [],
221+
details: null,
222+
accepted: () => {
223+
this.current_history_index = event.state['sveltekit:index'];
224+
},
225+
blocked: () => {
226+
const delta = this.current_history_index - event.state['sveltekit:index'];
227+
history.go(delta);
228+
}
229+
});
234230
});
235231
}
236232

@@ -273,35 +269,20 @@ export class Router {
273269
) {
274270
const url = new URL(href, get_base_uri(document));
275271

276-
if (this.enabled) {
277-
return this._navigate({
278-
url,
279-
scroll: noscroll ? scroll_state() : null,
280-
keepfocus,
281-
chain,
282-
details: {
283-
state,
284-
replaceState
285-
},
286-
accepted: () => {},
287-
blocked: () => {}
288-
});
289-
}
290-
291-
location.href = url.href;
292-
return new Promise(() => {
293-
/* never resolves */
272+
return this._navigate({
273+
url,
274+
scroll: noscroll ? scroll_state() : null,
275+
keepfocus,
276+
chain,
277+
details: {
278+
state,
279+
replaceState
280+
},
281+
accepted: () => {},
282+
blocked: () => {}
294283
});
295284
}
296285

297-
enable() {
298-
this.enabled = true;
299-
}
300-
301-
disable() {
302-
this.enabled = false;
303-
}
304-
305286
/**
306287
* @param {URL} url
307288
* @returns {Promise<import('./types').NavigationResult>}

0 commit comments

Comments
 (0)