Skip to content

Commit 3209e3f

Browse files
liitfrjescalan
authored andcommitted
Debug pushstate when there are more than one link in a page (#26)
* Debug pushstate when there are more than one link in a page * Before, if a page had more than one link, any click would drive to the ressource related to last link in the page
1 parent ef4657c commit 3209e3f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/script.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ if (window.history) {
1818
el.onclick = function (e) {
1919
e.preventDefault()
2020
var parser = document.createElement('a')
21-
parser.href = el.href
22-
var matchedTpl = _getTemplate(el.pathname)
21+
parser.href = e.target
22+
var matchedTpl = _getTemplate(e.target.pathname)
2323
if (matchedTpl) {
2424
document.write(matchedTpl)
2525
document.close()
26-
history.pushState({}, '', el.href)
26+
history.pushState({}, '', e.target)
2727
} else {
28-
window.location = el.href
28+
window.location = e.target
2929
}
3030
}
3131
}

0 commit comments

Comments
 (0)