Skip to content

Commit 95e38dc

Browse files
committed
oldHash -> local, many hashes
1 parent c929364 commit 95e38dc

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/Routing.purs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,15 @@ foreign import decodeURIComponent :: String -> String
2525
foreign import hashChanged """
2626
function hashChanged(handler) {
2727
return function() {
28-
var getHash = function() {return document.location.href.split('#')[1] || '';};
29-
window['__oldHash'] = "";
28+
var getHash = function() {
29+
return document.location.href.split('#').splice(1).join('#');
30+
};
31+
var oldHash = "";
3032
handler("")(getHash())();
3133
window.addEventListener("hashchange", function(ev) {
3234
var newHash = getHash();
33-
handler(window['__oldHash'])(newHash)();
34-
window['__oldHash'] = newHash;
35+
handler(oldHash)(newHash)();
36+
oldHash = newHash;
3537
});
3638
};
3739
}

src/Routing/Hash.purs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ function setHash(hash) {
1414

1515
foreign import getHash """
1616
function getHash() {
17-
return document.location.href.split('#')[1] || "";
17+
return document.location.href.split('#').splice(1).join('#');
1818
}
1919
""" :: forall e. Eff (dom :: DOM |e) String
2020

0 commit comments

Comments
 (0)