Skip to content

Commit f7905b7

Browse files
authored
- a11y fix - Added check to make sure link contains an anchor before preventing default - Fixed timing of escape function to prevent breaking anchor links when updating the URL - Switched from `location.origin` to `location.hostname` for better backwards compatibility
1 parent 89c19c5 commit f7905b7

File tree

6 files changed

+10
-10
lines changed

6 files changed

+10
-10
lines changed

dist/js/smooth-scroll.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* smooth-scroll v9.3.2: Animate scrolling to anchor links
2+
* smooth-scroll v9.4.1: Animate scrolling to anchor links
33
* (c) 2016 Chris Ferdinandi
44
* MIT License
55
* http://github.com/cferdinandi/smooth-scroll
@@ -449,7 +449,7 @@
449449
if ( toggle && toggle.tagName.toLowerCase() === 'a' ) {
450450

451451
// Check that link is an anchor and points to current page
452-
if ( toggle.origin !== location.origin || toggle.pathname !== location.pathname || !/#/.test(toggle.href) ) return;
452+
if ( toggle.hostname !== root.location.hostname || toggle.pathname !== root.location.pathname || !/#/.test(toggle.href) ) return;
453453

454454
event.preventDefault(); // Prevent default click event
455455
smoothScroll.animateScroll( toggle.hash, toggle, settings); // Animate scroll

dist/js/smooth-scroll.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/dist/js/smooth-scroll.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* smooth-scroll v9.3.2: Animate scrolling to anchor links
2+
* smooth-scroll v9.4.1: Animate scrolling to anchor links
33
* (c) 2016 Chris Ferdinandi
44
* MIT License
55
* http://github.com/cferdinandi/smooth-scroll
@@ -449,7 +449,7 @@
449449
if ( toggle && toggle.tagName.toLowerCase() === 'a' ) {
450450

451451
// Check that link is an anchor and points to current page
452-
if ( toggle.origin !== location.origin || toggle.pathname !== location.pathname || !/#/.test(toggle.href) ) return;
452+
if ( toggle.hostname !== root.location.hostname || toggle.pathname !== root.location.pathname || !/#/.test(toggle.href) ) return;
453453

454454
event.preventDefault(); // Prevent default click event
455455
smoothScroll.animateScroll( toggle.hash, toggle, settings); // Animate scroll

0 commit comments

Comments
 (0)