@@ -49,8 +49,6 @@ export class Router {
49
49
this . renderer = renderer ;
50
50
renderer . router = this ;
51
51
52
- this . enabled = true ;
53
-
54
52
// make it possible to reset focus
55
53
document . body . setAttribute ( 'tabindex' , '-1' ) ;
56
54
@@ -152,8 +150,6 @@ export class Router {
152
150
153
151
/** @param {MouseEvent } event */
154
152
addEventListener ( 'click' , ( event ) => {
155
- if ( ! this . enabled ) return ;
156
-
157
153
// Adapted from https://github.com/visionmedia/page.js
158
154
// MIT license https://github.com/visionmedia/page.js#license
159
155
if ( event . button || event . which !== 1 ) return ;
@@ -211,26 +207,26 @@ export class Router {
211
207
} ) ;
212
208
213
209
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
+ } ) ;
234
230
} ) ;
235
231
}
236
232
@@ -273,35 +269,20 @@ export class Router {
273
269
) {
274
270
const url = new URL ( href , get_base_uri ( document ) ) ;
275
271
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 : ( ) => { }
294
283
} ) ;
295
284
}
296
285
297
- enable ( ) {
298
- this . enabled = true ;
299
- }
300
-
301
- disable ( ) {
302
- this . enabled = false ;
303
- }
304
-
305
286
/**
306
287
* @param {URL } url
307
288
* @returns {Promise<import('./types').NavigationResult> }
0 commit comments