router: be a little more robust

This commit is contained in:
Nils Schneider 2015-03-31 16:30:16 +02:00
parent 3b5895601d
commit 3c3cb4047d

View file

@ -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
}
}