File tree Expand file tree Collapse file tree 2 files changed +11
-5
lines changed
Expand file tree Collapse file tree 2 files changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -25,10 +25,15 @@ 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() {
29+ return document.location.href.split('#').splice(1).join('#');
30+ };
31+ var oldHash = " " ;
32+ handler(" " )(getHash())();
3033 window.addEventListener(" hashchange " , function(ev) {
31- handler(ev.oldURL)(ev.newURL)();
34+ var newHash = getHash();
35+ handler(oldHash)(newHash)();
36+ oldHash = newHash;
3237 });
3338 };
3439}
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('#').splice(1).join('#' );
1718}
1819" " " :: forall e . Eff (dom :: DOM |e ) String
1920
You can’t perform that action at this time.
0 commit comments