@@ -18,6 +18,19 @@ function getNextTabId() {
1818 return ++ tabId ;
1919}
2020
21+ var isLocal = ( function ( ) {
22+ var rhash = / # .* $ / ,
23+ currentPage = location . href . replace ( rhash , "" ) ;
24+
25+ return function ( anchor ) {
26+ // clone the node to work around IE 6 not normalizing the href property
27+ // if it's manually set, i.e., a.href = "#foo" kills the normalization
28+ anchor = anchor . cloneNode ( ) ;
29+ return anchor . hash . length > 1 &&
30+ anchor . href . replace ( rhash , "" ) === currentPage ;
31+ } ;
32+ } ) ( ) ;
33+
2134$ . widget ( "ui.tabs" , {
2235 version : "@VERSION" ,
2336 options : {
@@ -197,8 +210,7 @@ $.widget( "ui.tabs", {
197210 } ,
198211
199212 _processTabs : function ( ) {
200- var self = this ,
201- fragmentId = / ^ # .+ / ; // Safari 2 reports '#' for an empty hash
213+ var self = this ;
202214
203215 this . list = this . element . find ( "ol,ul" ) . eq ( 0 ) ;
204216 this . lis = $ ( " > li:has(a[href])" , this . list ) ;
@@ -208,40 +220,21 @@ $.widget( "ui.tabs", {
208220 this . panels = $ ( [ ] ) ;
209221
210222 this . anchors . each ( function ( i , a ) {
211- var href = $ ( a ) . attr ( "href" ) ,
212- hrefBase = href . split ( "#" ) [ 0 ] ,
213- selector ,
214- panel ,
215- baseEl ;
216-
217- // For dynamically created HTML that contains a hash as href IE < 8 expands
218- // such href to the full page url with hash and then misinterprets tab as ajax.
219- // Same consideration applies for an added tab with a fragment identifier
220- // since a[href=#fragment-identifier] does unexpectedly not match.
221- // Thus normalize href attribute...
222- if ( hrefBase && ( hrefBase === location . toString ( ) . split ( "#" ) [ 0 ] ||
223- ( baseEl = $ ( "base" ) [ 0 ] ) && hrefBase === baseEl . href ) ) {
224- href = a . hash ;
225- a . href = href ;
226- }
223+ var selector , panel ;
227224
228225 // inline tab
229- if ( fragmentId . test ( href ) ) {
230- selector = href ;
226+ if ( isLocal ( a ) ) {
227+ selector = a . hash ;
231228 panel = self . element . find ( self . _sanitizeSelector ( selector ) ) ;
232229 // remote tab
233- // prevent loading the page itself if href is just "#"
234- } else if ( href && href !== "#" ) {
230+ } else {
235231 var id = self . _tabId ( a ) ;
236232 selector = "#" + id ;
237233 panel = self . element . find ( selector ) ;
238234 if ( ! panel . length ) {
239235 panel = self . _createPanel ( id ) ;
240236 panel . insertAfter ( self . panels [ i - 1 ] || self . list ) ;
241237 }
242- // invalid tab href
243- } else {
244- self . options . disabled . push ( i ) ;
245238 }
246239
247240 if ( panel . length ) {
@@ -525,21 +518,18 @@ $.widget( "ui.tabs", {
525518 options = this . options ,
526519 anchor = this . anchors . eq ( index ) ,
527520 panel = self . _getPanelForTab ( anchor ) ,
528- // TODO until #3808 is fixed strip fragment identifier from url
529- // (IE fails to load from such url)
530- url = anchor . attr ( "href" ) . replace ( / # .* $ / , "" ) ,
531521 eventData = {
532522 tab : anchor ,
533523 panel : panel
534524 } ;
535525
536526 // not remote
537- if ( ! url ) {
527+ if ( isLocal ( anchor [ 0 ] ) ) {
538528 return ;
539529 }
540530
541531 this . xhr = $ . ajax ( {
542- url : url ,
532+ url : anchor . attr ( "href" ) ,
543533 beforeSend : function ( jqXHR , settings ) {
544534 return self . _trigger ( "beforeLoad" , event ,
545535 $ . extend ( { jqXHR : jqXHR , ajaxSettings : settings } , eventData ) ) ;
0 commit comments