mirror of
https://github.com/kevin-DL/sapper.git
synced 2026-01-21 14:55:04 +00:00
named exports, for tree-shakeability when we add new stuff
This commit is contained in:
@@ -2,7 +2,7 @@ const detach = node => {
|
|||||||
node.parentNode.removeChild(node);
|
node.parentNode.removeChild(node);
|
||||||
};
|
};
|
||||||
|
|
||||||
let component;
|
export let component;
|
||||||
let target;
|
let target;
|
||||||
let routes;
|
let routes;
|
||||||
|
|
||||||
@@ -158,28 +158,26 @@ function findAnchor(node) {
|
|||||||
|
|
||||||
let inited;
|
let inited;
|
||||||
|
|
||||||
const app = {
|
export function init(_target, _routes) {
|
||||||
init(_target, _routes) {
|
target = _target;
|
||||||
target = _target;
|
routes = _routes;
|
||||||
routes = _routes;
|
|
||||||
|
|
||||||
if (!inited) { // this check makes HMR possible
|
if (!inited) { // this check makes HMR possible
|
||||||
window.addEventListener('click', handle_click);
|
window.addEventListener('click', handle_click);
|
||||||
window.addEventListener('popstate', handle_popstate);
|
window.addEventListener('popstate', handle_popstate);
|
||||||
|
|
||||||
// prefetch
|
// prefetch
|
||||||
window.addEventListener('touchstart', prefetch);
|
window.addEventListener('touchstart', prefetch);
|
||||||
window.addEventListener('mouseover', prefetch);
|
window.addEventListener('mouseover', prefetch);
|
||||||
|
|
||||||
inited = true;
|
inited = true;
|
||||||
}
|
|
||||||
|
|
||||||
const scroll = scroll_history[uid] = scroll_state();
|
|
||||||
|
|
||||||
history.replaceState({ id: uid }, '', window.location.href);
|
|
||||||
navigate(new URL(window.location), uid);
|
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
const scroll = scroll_history[uid] = scroll_state();
|
||||||
|
|
||||||
|
history.replaceState({ id: uid }, '', window.location.href);
|
||||||
|
navigate(new URL(window.location), uid);
|
||||||
|
}
|
||||||
|
|
||||||
function which(event) {
|
function which(event) {
|
||||||
event = event || window.event;
|
event = event || window.event;
|
||||||
@@ -191,6 +189,4 @@ function scroll_state() {
|
|||||||
x: window.scrollX,
|
x: window.scrollX,
|
||||||
y: window.scrollY
|
y: window.scrollY
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export default app;
|
|
||||||
Reference in New Issue
Block a user