mirror of
https://github.com/kevin-DL/sapper.git
synced 2026-01-14 03:54:46 +00:00
detach SSRd <head> contents
This commit is contained in:
22
runtime/app.js
Normal file
22
runtime/app.js
Normal file
@@ -0,0 +1,22 @@
|
||||
const app = {
|
||||
init(callback) {
|
||||
window.addEventListener('click', event => {
|
||||
let a = event.target;
|
||||
while (a && a.nodeName !== 'A') a = a.parentNode;
|
||||
if (!a) return;
|
||||
|
||||
if (callback(new URL(a.href))) {
|
||||
event.preventDefault();
|
||||
history.pushState({}, '', a.href);
|
||||
}
|
||||
});
|
||||
|
||||
window.addEventListener('popstate', event => {
|
||||
callback(window.location);
|
||||
});
|
||||
|
||||
callback(window.location);
|
||||
}
|
||||
};
|
||||
|
||||
export default app;
|
||||
Reference in New Issue
Block a user