Skip to content

Commit 436e134

Browse files
committed
fix(plugin): check if scroll target exists in animation plugin
1 parent e59fe64 commit 436e134

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

source/js/animation.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,11 @@
5252
// jump to location.hash
5353
if (window.location.hash) {
5454
setTimeout(() => {
55-
// Use getElementById because querySelector does not support ids that start with numbers
56-
document.getElementById(window.location.hash.substring(1)).scrollIntoView({ behavior: 'smooth' });
55+
const id = '#' + CSS.escape(window.location.hash.substring(1));
56+
const target = document.querySelector(id);
57+
if (target) {
58+
target.scrollIntoView({ behavior: 'smooth' });
59+
}
5760
}, i * 100);
5861
}
5962
});

0 commit comments

Comments
 (0)