diff --git a/lib/History.js b/lib/History.js index e844fea..602b065 100644 --- a/lib/History.js +++ b/lib/History.js @@ -71,9 +71,16 @@ History.prototype._update = function(historyMethod, relativeUrl, render, state, var options = renderOptions(e, path) state.$render = true state.$method = options.method - window.history[historyMethod](state, null, options.url) + window.history[historyMethod](state, null, options.url + (url.hash || '')) currentPath = window.location.pathname + window.location.search if (render) router.render(this, options, e) + // Jump to named element on new page, to mimic browser behavior + if (url.hash) { + var hashElement = document.getElementById(url.hash.substring(1)) + if (hashElement) { + hashElement.scrollIntoView() + } + } } History.prototype.page = function() {