MCPcopy
hub / github.com/docsifyjs/docsify / initRouter

Method initRouter

src/core/router/index.js:37–65  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

35 }
36
37 initRouter() {
38 const config = this.config;
39 const mode = config.routerMode || 'hash';
40 let router;
41
42 if (mode === 'history' && supportsPushState) {
43 router = new HTML5History(config);
44 } else {
45 router = new HashHistory(config);
46 }
47
48 this.router = router;
49 this.updateRender();
50 lastRoute = this.route;
51
52 // eslint-disable-next-line no-unused-vars
53 router.onchange(params => {
54 this.updateRender();
55 this._updateRender();
56
57 if (lastRoute.path === this.route.path) {
58 this.$resetEvents(params.source);
59 return;
60 }
61
62 this.$fetch(noop, this.$resetEvents.bind(this, params.source));
63 lastRoute = this.route;
64 });
65 }
66 };
67}

Callers 1

constructorMethod · 0.80

Calls 5

updateRenderMethod · 0.95
_updateRenderMethod · 0.80
$resetEventsMethod · 0.80
$fetchMethod · 0.80
onchangeMethod · 0.45

Tested by

no test coverage detected