fix pushState event (#434)

This commit is contained in:
Yoshua Wuyts
2017-03-22 20:42:53 +01:00
committed by GitHub
parent 5602bc039b
commit c2e4bb4963
+7 -5
View File
@@ -57,7 +57,12 @@ function Framework (opts) {
if (opts.history !== false) { if (opts.history !== false) {
onHistoryChange(function (href) { onHistoryChange(function (href) {
bus.emit('pushState', window.location.href) bus.emit('pushState')
})
bus.on('pushState', function (href) {
if (href) window.history.pushState({}, null, href)
bus.emit('render')
scrollIntoView() scrollIntoView()
}) })
@@ -66,10 +71,7 @@ function Framework (opts) {
var href = location.href var href = location.href
var currHref = window.location.href var currHref = window.location.href
if (href === currHref) return if (href === currHref) return
window.history.pushState({}, null, href) bus.emit('pushState', href)
bus.emit('pushState', window.location.href)
bus.emit('render')
scrollIntoView()
}) })
} }
} }