Skip to content

Commit b37f577

Browse files
committed
Ensure links to nonexistent elements don't trigger scroll. Fixes kswedberg#92.
1 parent b192367 commit b37f577

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/jquery.smooth-scroll.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,10 @@
148148
var pathMatch = thisOpts.scrollTarget || (linkPath === locationPath);
149149
var thisHash = escapeSelector(link.hash);
150150

151+
if (thisHash && !$(thisHash).length) {
152+
include = false;
153+
}
154+
151155
if (!thisOpts.scrollTarget && (!hostMatch || !pathMatch || !thisHash)) {
152156
include = false;
153157
} else {

0 commit comments

Comments
 (0)