Fix DOMException when location.hash is invalid selector

This commit is contained in:
Thomas Ghysels
2018-01-26 02:24:49 +01:00
committed by GitHub
parent 8bad37205d
commit b53ee061c0

View File

@@ -208,7 +208,7 @@ export function init(_target: Node, _routes: Route[]) {
setTimeout(() => {
const { hash, href } = window.location;
const deep_linked = hash && document.querySelector(hash);
const deep_linked = hash && document.getElementById(hash.slice(1));
scroll_history[uid] = deep_linked ?
{ x: 0, y: deep_linked.getBoundingClientRect().top } :
scroll_state();