Files
buuh/lib/history.js
T

20 lines
486 B
JavaScript
Raw Normal View History

2017-03-21 03:00:45 +01:00
var assert = require('assert')
module.exports = history
// listen to html5 pushstate events
// and update router accordingly
// fn(str) -> null
function history (cb) {
assert.equal(typeof cb, 'function', 'sheet-router/history: cb must be a function')
window.onpopstate = function () {
2017-04-07 18:19:23 +02:00
var obj = {
2017-03-21 03:00:45 +01:00
pathname: document.location.pathname,
search: document.location.search,
href: document.location.href,
hash: document.location.hash
2017-04-07 18:19:23 +02:00
}
cb(obj)
2017-03-21 03:00:45 +01:00
}
}