fix navigation and ESM stuff

This commit is contained in:
Rich Harris
2017-12-11 18:05:07 -05:00
parent c6778c961b
commit 33fcb865c8
3 changed files with 10 additions and 3 deletions

View File

@@ -3,7 +3,14 @@ window.addEventListener('click', event => {
while (a && a.nodeName !== 'A') a = a.parentNode;
if (!a) return;
if (navigate(new URL(a.href))) event.preventDefault();
if (navigate(new URL(a.href))) {
event.preventDefault();
history.pushState({}, '', a.href);
}
});
window.addEventListener('popstate', event => {
navigate(window.location);
});
const target = document.querySelector('main');