sheet-router
Advanced tools
Comparing version 2.0.3 to 2.0.4
@@ -7,6 +7,8 @@ const window = require('global/window') | ||
// handle a click if is anchor tag with an href | ||
// and url lives on the same domain | ||
// and url lives on the same domain. Replaces | ||
// trailing '#' so empty links work as expected. | ||
// fn(str) -> null | ||
function history (cb) { | ||
assert.equal(typeof cb, 'function', 'cb must be a function') | ||
window.onclick = function (e) { | ||
@@ -16,6 +18,7 @@ if (e.target.localName !== 'a') return | ||
if (window.location.host !== e.target.host) return | ||
const href = e.target.href.replace(/#$/, '') | ||
e.preventDefault() | ||
cb(e.target.href) | ||
window.history.pushState({}, null, e.target.href) | ||
cb(href) | ||
window.history.pushState({}, null, href) | ||
} | ||
} |
{ | ||
"name": "sheet-router", | ||
"version": "2.0.3", | ||
"version": "2.0.4", | ||
"description": "Fast, modular client router", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -114,2 +114,4 @@ # sheet-router [![stability][0]][1] | ||
``` | ||
It is good practice to represent JS actions as `<a href="#">`, as a good | ||
number of components in the wild expect `<a>` tags to have an `href` value. | ||
@@ -116,0 +118,0 @@ ### virtual-dom example |
16085
270
216