File tree Expand file tree Collapse file tree 2 files changed +9
-5
lines changed
Expand file tree Collapse file tree 2 files changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -25,10 +25,13 @@ foreign import decodeURIComponent :: String -> String
2525foreign import hashChanged " " "
2626function hashChanged(handler) {
2727 return function() {
28- var currentHash = document.location.hash;
29- handler(" " )(currentHash)();
28+ var getHash = function() {return document.location.href.split('#')[1] || '';};
29+ window['__oldHash'] = " " ;
30+ handler(" " )(getHash())();
3031 window.addEventListener(" hashchange " , function(ev) {
31- handler(ev.oldURL)(ev.newURL)();
32+ var newHash = getHash();
33+ handler(window['__oldHash'])(newHash)();
34+ window['__oldHash'] = newHash;
3235 });
3336 };
3437}
Original file line number Diff line number Diff line change @@ -6,14 +6,15 @@ import DOM
66foreign import setHash " " "
77function setHash(hash) {
88 return function() {
9- document.location.hash = hash;
9+ var uri = document.location.href.split('#')[0];
10+ document.location.href = uri + '#' + hash;
1011 };
1112}
1213" " " :: forall e . String -> Eff (dom :: DOM |e ) Unit
1314
1415foreign import getHash " " "
1516function getHash() {
16- return document.location.hash.replace(/^[^#]*#/g, " " ) ;
17+ return document.location.href.split('#')[1] || " " ;
1718}
1819" " " :: forall e . Eff (dom :: DOM |e ) String
1920
You can’t perform that action at this time.
0 commit comments