cferdinandi/smooth-scroll

topOnEmptyHash error

Closed this issue · 2 comments

For links with just a hash in them I wanted to prevent them to scroll to the top. I set the following option topOnEmptyHash: false. This option results in an error in the console: Uncaught DOMException: Failed to execute 'querySelector' on 'Document': '#' is not a valid selector.

Am I doing something wrong or is that a bug?

Test case: https://codepen.io/imranparkar/pen/vPVpwO

Hi there. I need to put in a better check to prevent the error from being thrown, so thanks for this.

I do want to make clear, though, that the jump to the top will still happen. The scroll just won't be animated.