{"action":"created","issue":{"url":"https://api.github.com/repos/lhorie/mithril.js/issues/960","repository_url":"https://api.github.com/repos/lhorie/mithril.js","labels_url":"https://api.github.com/repos/lhorie/mithril.js/issues/960/labels{/name}","comments_url":"https://api.github.com/repos/lhorie/mithril.js/issues/960/comments","events_url":"https://api.github.com/repos/lhorie/mithril.js/issues/960/events","html_url":"https://github.com/lhorie/mithril.js/issues/960","id":133870453,"number":960,"title":"m.route as config function loses hash information","user":{"login":"tivac","id":49545,"avatar_url":"https://avatars.githubusercontent.com/u/49545?v=3","gravatar_id":"","url":"https://api.github.com/users/tivac","html_url":"https://github.com/tivac","followers_url":"https://api.github.com/users/tivac/followers","following_url":"https://api.github.com/users/tivac/following{/other_user}","gists_url":"https://api.github.com/users/tivac/gists{/gist_id}","starred_url":"https://api.github.com/users/tivac/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tivac/subscriptions","organizations_url":"https://api.github.com/users/tivac/orgs","repos_url":"https://api.github.com/users/tivac/repos","events_url":"https://api.github.com/users/tivac/events{/privacy}","received_events_url":"https://api.github.com/users/tivac/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-02-16T02:57:28Z","updated_at":"2016-02-16T11:33:20Z","closed_at":null,"body":"We're using `m.route.mode = \"pathname\";` and have some links that point deeply into another section of the site, `<a href=\"/en/teams#fooga-wooga\">`. When those links are using `config : m.route` they are stripped of the hash portion of the their URL, so the resulting route is just `/en/teams`.\r\n\r\nThis is happening because of https://github.com/lhorie/mithril.js/blob/next/mithril.js#L1665\r\n\r\n```js\r\nm.route(currentTarget[m.route.mode]\r\n\t\t\t.slice(modes[m.route.mode].length), args)\r\n```\r\n\r\nbecause of how anchor element properties work in the DOM when requesting `currentTarget.pathName` (in this case) it gives back the pathname only, stripped of any query params or hash values. This is then passed directly into `m.route()` and that information is lost.\r\n\r\nInterestingly, the `m.route()` matching code wouldn't know what to do w/ a hash or a query string anyways, because calling `m.route(\"/en/teams#fooga-wooga\");` doesn't match our `/:lang/teams` route.\r\n\r\nIs this a known issue? It seems like it must be but I wasn't able to dredge up any mentions of it. Is there a good workaround? The only ones I can come up w/ atm are to remove the `config : m.route` handler entirely (thus losing all the nice SPA-ness), or to remove it and add our own `onclick` handler to save off the hash somewhere and re-apply it after the route changes.\r\n\r\nBoth of those sound pretty gross."},"comment":{"url":"https://api.github.com/repos/lhorie/mithril.js/issues/comments/184643961","html_url":"https://github.com/lhorie/mithril.js/issues/960#issuecomment-184643961","issue_url":"https://api.github.com/repos/lhorie/mithril.js/issues/960","id":184643961,"user":{"login":"barneycarroll","id":83627,"avatar_url":"https://avatars.githubusercontent.com/u/83627?v=3","gravatar_id":"","url":"https://api.github.com/users/barneycarroll","html_url":"https://github.com/barneycarroll","followers_url":"https://api.github.com/users/barneycarroll/followers","following_url":"https://api.github.com/users/barneycarroll/following{/other_user}","gists_url":"https://api.github.com/users/barneycarroll/gists{/gist_id}","starred_url":"https://api.github.com/users/barneycarroll/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/barneycarroll/subscriptions","organizations_url":"https://api.github.com/users/barneycarroll/orgs","repos_url":"https://api.github.com/users/barneycarroll/repos","events_url":"https://api.github.com/users/barneycarroll/events{/privacy}","received_events_url":"https://api.github.com/users/barneycarroll/received_events","type":"User","site_admin":false},"created_at":"2016-02-16T11:33:20Z","updated_at":"2016-02-16T11:33:20Z","body":"[Here's a demo allowing you to switch route modes](https://jsfiddle.net/barney/jpwL5v6v/3/), which shows the hash being lost in pathname & search modes, and here's a [partial fix](https://jsfiddle.net/barney/jpwL5v6v/4/) using [this fork](https://github.com/barneycarroll/mithril.js/blob/preserveRouteSegments/mithril.js#L801) (ie via fix proposed above). Doesn't resolve pathname mode."}}