From: Nicolas Coden Date: Tue, 9 Oct 2018 22:36:54 +0000 (+0200) Subject: fix: ensure Tab deep-linking to redirect to hash with "#" X-Git-Tag: v6.6.0~3^2~84^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7bccec66f;p=thirdparty%2Ffoundation%2Ffoundation-sites.git fix: ensure Tab deep-linking to redirect to hash with "#" Related to https://github.com/zurb/foundation-sites/issues/11527 --- diff --git a/js/foundation.tabs.js b/js/foundation.tabs.js index 151312461..cf86e5d4e 100644 --- a/js/foundation.tabs.js +++ b/js/foundation.tabs.js @@ -258,8 +258,9 @@ class Tabs extends Plugin { var $oldTab = this.$element. find(`.${this.options.linkClass}.${this.options.linkActiveClass}`), $tabLink = $target.find('[role="tab"]'), - hash = $tabLink.attr('data-tabs-target') || $tabLink[0].hash.slice(1), - $targetContent = this.$tabContent.find(`#${hash}`); + target = $tabLink.attr('data-tabs-target'), + anchor = target && target.length ? `#${target}` : $tabLink[0].hash, + $targetContent = this.$tabContent.find(anchor); //close old tab this._collapseTab($oldTab); @@ -270,9 +271,9 @@ class Tabs extends Plugin { //either replace or update browser history if (this.options.deepLink && !historyHandled) { if (this.options.updateHistory) { - history.pushState({}, '', hash); + history.pushState({}, '', anchor); } else { - history.replaceState({}, '', hash); + history.replaceState({}, '', anchor); } }