From b44cf71d804f35d7c3657abe7619a79a60875e96 Mon Sep 17 00:00:00 2001 From: Yuxin Wu Date: Thu, 15 Sep 2022 22:34:24 -0700 Subject: [PATCH] Fix support for hashes that start with numbers QuerySelector does not work with ids that start with numbers: https://stackoverflow.com/questions/20306204/using-queryselector-with-ids-that-are-numbers https://github.com/madrobby/zepto/issues/1333 --- source/js/animation.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/js/animation.js b/source/js/animation.js index e79be6f..c641f06 100644 --- a/source/js/animation.js +++ b/source/js/animation.js @@ -52,7 +52,8 @@ // jump to location.hash if (window.location.hash) { setTimeout(() => { - document.querySelector(window.location.hash).scrollIntoView({ behavior: 'smooth' }); + // Use getElementById because querySelector does not support ids that start with numbers + document.getElementById(window.location.hash.substring(1)).scrollIntoView({ behavior: 'smooth' }); }, i * 100); } });