Bug in QJueryUI TAB widget

Bug in QJueryUI TAB widget

Hi all,

I just found out a bug in JQuery TAB widget. The bug occurs when you invoke the page which contains the widget with a different URL. For Example:

Both URL are actually the same, the first URL is normally used by human beings, because the browser knows automatically when basic-auth is required, shows a dialog, and then continues with the basic-auth header. But when you want to make automated testing, you normally use the second URL where you have the basic-auth credentials automatically provided.

What happens now is that the TAB widget automatically tries to load the TAB content via AJAX, but the way I use TABs no AJAX is invoked. So what happens is that the TAB widget loads the main page again, and again, and again in an infinite loop.

The reason for this is that the TAB widget tries heuristically to find out whether it is local or not using the function _isLocal, which looks like this and does not support such kind of URLS:


    _isLocal: ( function() {
        var rhash = /#.*$/;

        return function( anchor ) {
            var anchorUrl, locationUrl;

            anchorUrl = anchor.href.replace( rhash, "" );
            locationUrl = location.href.replace( rhash, "" );

            // Decoding may throw an error if the URL isn't UTF-8 (#9518)
            try {
                anchorUrl = decodeURIComponent( anchorUrl );
            } catch ( error ) {}
            try {
                locationUrl = decodeURIComponent( locationUrl );
            } catch ( error ) {}

            return anchor.hash.length > 1 && anchorUrl === locationUrl;
        };
    } )(),
 
My current workaround is to overwrite this function and just always return true, because in our webapp, we don't use AJAX to display the content.


    jQuery.ui.tabs.prototype._isLocal = ( function() {
        return function( anchor ) {
            // All our JQuery UI tabs are local
            return true;
        };
    } )();


But this hack is ugly, because when updating JQueryUI to a new version, it will not work, I assume. So my suggestion is actually to get away with this heuristics whether the TAB content is local or not, and add a property which can be set from outside.

What is the opinion about this in this forum? Do you guys agree?