From 7bccec66f64498a81389eddb95abaa795933dded Mon Sep 17 00:00:00 2001 From: Nicolas Coden Date: Wed, 10 Oct 2018 00:36:54 +0200 Subject: [PATCH] fix: ensure Tab deep-linking to redirect to hash with "#" Related to https://github.com/zurb/foundation-sites/issues/11527 --- js/foundation.tabs.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) 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); } } -- 2.47.2