From 3c3cb4047d4018740421590f42b9bc25e432a005 Mon Sep 17 00:00:00 2001 From: Nils Schneider Date: Tue, 31 Mar 2015 16:30:16 +0200 Subject: [PATCH] router: be a little more robust --- lib/router.js | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/lib/router.js b/lib/router.js index 2bc38f5..df3bc6f 100644 --- a/lib/router.js +++ b/lib/router.js @@ -30,15 +30,25 @@ define(function () { } function gotoNode(d) { + if (!d) + return false + targets.forEach( function (t) { t.gotoNode(d) }) + + return true } function gotoLink(d) { + if (!d) + return false + targets.forEach( function (t) { t.gotoLink(d) }) + + return true } function loadState(s) { @@ -80,16 +90,18 @@ define(function () { self.node = function (d) { return function () { - gotoNode(d) - saveState({ node: d }) + if (gotoNode(d)) + saveState({ node: d }) + return false } } self.link = function (d) { return function () { - gotoLink(d) - saveState({ link: d }) + if (gotoLink(d)) + saveState({ link: d }) + return false } }