@@ -101,36 +101,38 @@ class Tabs extends Plugin {
101
101
}
102
102
}
103
103
104
- //current context-bound function to open tabs on page load or history hashchange
104
+ // Current context-bound function to open tabs on page load or history hashchange
105
105
this . _checkDeepLink = ( ) => {
106
106
var anchor = window . location . hash ;
107
107
108
- // if there is no anchor, return to the initial tab
108
+ // If there is no anchor, return to the initial panel
109
109
if ( ! anchor . length && this . _initialAnchor ) {
110
110
anchor = this . _initialAnchor ;
111
111
}
112
112
113
- //need a hash and a relevant anchor in this tabset
114
- if ( anchor . length ) {
115
- var anchorNoHash = ( anchor . indexOf ( '#' ) >= 0 ? anchor . slice ( 1 ) : anchor ) ;
116
- var $link = this . $element . find ( `[href$="${ anchor } "],[data-tabs-target="${ anchorNoHash } "]` ) . first ( ) ;
117
- if ( $link . length ) {
118
- this . selectTab ( $ ( anchor ) , true ) ;
119
-
120
- //roll up a little to show the titles
121
- if ( this . options . deepLinkSmudge ) {
122
- var offset = this . $element . offset ( ) ;
123
- $ ( 'html, body' ) . animate ( { scrollTop : offset . top } , this . options . deepLinkSmudgeDelay ) ;
124
- }
113
+ var anchorNoHash = anchor . indexOf ( '#' ) >= 0 ? anchor . slice ( 1 ) : anchor ;
114
+ var $anchor = anchorNoHash && $ ( `#${ anchorNoHash } ` ) ;
115
+ var $link = anchor && this . $element . find ( `[href$="${ anchor } "],[data-tabs-target="${ anchorNoHash } "]` ) . first ( ) ;
116
+
117
+ // If there is an anchor for the hash, select it
118
+ if ( $anchor && $anchor . length && $link && $link . length ) {
119
+ this . selectTab ( $anchor , true ) ;
120
+ }
121
+
122
+ // Roll up a little to show the titles
123
+ if ( this . options . deepLinkSmudge ) {
124
+ var offset = this . $element . offset ( ) ;
125
+ $ ( 'html, body' ) . animate ( { scrollTop : offset . top } , this . options . deepLinkSmudgeDelay ) ;
126
+ }
125
127
126
- /**
127
- * Fires when the zplugin has deeplinked at pageload
128
- * @event Tabs#deeplink
129
- */
130
- this . $element . trigger ( 'deeplink.zf.tabs' , [ $link , $ ( anchor ) ] ) ;
131
- }
132
- }
133
- }
128
+ if ( $anchor && $link ) {
129
+ /**
130
+ * Fires when the zplugin has deeplinked at pageload
131
+ * @event Tabs#deeplink
132
+ */
133
+ this . $element . trigger ( 'deeplink.zf.tabs' , [ $link , $anchor ] ) ;
134
+ }
135
+ }
134
136
135
137
//use browser to open a tab, if it exists in this tabset
136
138
if ( this . options . deepLink ) {
@@ -360,6 +362,7 @@ class Tabs extends Plugin {
360
362
361
363
this . _handleTabChange ( $target , historyHandled ) ;
362
364
} ;
365
+
363
366
/**
364
367
* Sets the height of each panel to the height of the tallest panel.
365
368
* If enabled in options, gets called on media query change.
0 commit comments