Skip to content

Commit

Permalink
fix(router): check properly the debug mode for logging navigation events
Browse files Browse the repository at this point in the history
  • Loading branch information
smalluban committed Sep 27, 2024
1 parent 8d36523 commit 5ddd74c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
11 changes: 9 additions & 2 deletions src/router.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
import * as cache from "./cache.js";
import { deferred, dispatch, walkInShadow, debug } from "./utils.js";
import { constructors } from "./define.js";

import {
deferred,
dispatch,
walkInShadow,
debug,
isDebugMode,
} from "./utils.js";

const connect = Symbol("router.connect");
const configs = new WeakMap();

Expand Down Expand Up @@ -1139,7 +1146,7 @@ function router(views, options) {
return connectRootRouter(host, invalidate, options);
},
observe:
debug &&
isDebugMode() &&
((host, value, lastValue) => {
const index = value.length - 1;
const view = value[index];
Expand Down
8 changes: 4 additions & 4 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ export function walkInShadow(target, cb) {
}

let debugMode = false;
export function debug() {
debugMode = true;
}

export function isDebugMode() {
return debugMode;
}

export function debug() {
debugMode = true;
}

export const deferred = Promise.resolve();
export const storePointer = new WeakMap();

0 comments on commit 5ddd74c

Please sign in to comment.