Skip to content

Commit

Permalink
[fix] refactor navigation singletons to avoid storing undefined refer…
Browse files Browse the repository at this point in the history
…ence (#3374)

Co-authored-by: Rich Harris <hello@rich-harris.dev>
Co-authored-by: Bjorn Lu <bjornlu.dev@gmail.com>
Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com>
  • Loading branch information
4 people committed Jan 18, 2022
1 parent cbe15c7 commit 86f8f8a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/brown-mangos-tie.md
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

[fix] refactor navigation singletons to avoid storing undefined reference
4 changes: 1 addition & 3 deletions packages/kit/src/runtime/app/navigation.js
@@ -1,8 +1,6 @@
import { router as router_, renderer } from '../client/singletons.js';
import { router, renderer } from '../client/singletons.js';
import { get_base_uri } from '../client/utils.js';

const router = /** @type {import('../client/router').Router} */ (router_);

/**
* @param {string} name
*/
Expand Down
7 changes: 5 additions & 2 deletions packages/kit/src/runtime/client/singletons.js
@@ -1,4 +1,7 @@
/** @type {import('./router').Router?} */
/**
* The router is nullable, but not typed that way for ease-of-use
* @type {import('./router').Router}
*/
export let router;

/** @type {import('./renderer').Renderer} */
Expand All @@ -11,6 +14,6 @@ export let renderer;
* }} opts
*/
export function init(opts) {
router = opts.router;
router = /** @type {import('../client/router').Router} */ (opts.router);
renderer = opts.renderer;
}

0 comments on commit 86f8f8a

Please sign in to comment.