From b53ee061c07c85e105f49f124242615505afdc20 Mon Sep 17 00:00:00 2001 From: Thomas Ghysels Date: Fri, 26 Jan 2018 02:24:49 +0100 Subject: [PATCH] Fix DOMException when location.hash is invalid selector --- src/runtime/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/runtime/index.ts b/src/runtime/index.ts index c30a89d8c..ec0aecd6a 100644 --- a/src/runtime/index.ts +++ b/src/runtime/index.ts @@ -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();