From eef633e32a20ad93355060a8eef4b2129cf0bc5c Mon Sep 17 00:00:00 2001 From: Alex Rhea Date: Tue, 3 Jan 2012 13:00:02 -0500 Subject: [PATCH 1/2] Bug fix for isLocal function in jQuery Tabs. isLocal function was not compatible with HTML5 push state as the url could have changed since the page was loaded as in cases with Backbone.js --- ui/jquery.ui.tabs.js | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/ui/jquery.ui.tabs.js b/ui/jquery.ui.tabs.js index 5c9fc1326ae..3e022af4a8f 100644 --- a/ui/jquery.ui.tabs.js +++ b/ui/jquery.ui.tabs.js @@ -18,18 +18,13 @@ function getNextTabId() { return ++tabId; } -var isLocal = (function() { - var rhash = /#.*$/, - currentPage = location.href.replace( rhash, "" ); - - return function( anchor ) { - // clone the node to work around IE 6 not normalizing the href property - // if it's manually set, i.e., a.href = "#foo" kills the normalization - anchor = anchor.cloneNode( false ); - return anchor.hash.length > 1 && - anchor.href.replace( rhash, "" ) === currentPage; - }; -})(); +var isLocal = function( anchor ) { + var rhash = /#.*$/; + // clone the node to work around IE 6 not normalizing the href property + // if it's manually set, i.e., a.href = "#foo" kills the normalization + anchor = anchor.cloneNode( false ); + return anchor.hash.length > 1 && anchor.href.replace( rhash, "" ) === location.href.replace( rhash, "" ); +}; $.widget( "ui.tabs", { version: "@VERSION", From 3c4e40d8d770ac117969b2cb011ac3d7402a134a Mon Sep 17 00:00:00 2001 From: Alex Rhea Date: Tue, 3 Jan 2012 13:18:13 -0500 Subject: [PATCH 2/2] Removed regex from function and split return into two lines. --- ui/jquery.ui.tabs.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ui/jquery.ui.tabs.js b/ui/jquery.ui.tabs.js index 3e022af4a8f..0429363f22f 100644 --- a/ui/jquery.ui.tabs.js +++ b/ui/jquery.ui.tabs.js @@ -13,17 +13,19 @@ */ (function( $, undefined ) { -var tabId = 0; +var tabId = 0, + rhash = /#.*$/; + function getNextTabId() { return ++tabId; } var isLocal = function( anchor ) { - var rhash = /#.*$/; // clone the node to work around IE 6 not normalizing the href property // if it's manually set, i.e., a.href = "#foo" kills the normalization anchor = anchor.cloneNode( false ); - return anchor.hash.length > 1 && anchor.href.replace( rhash, "" ) === location.href.replace( rhash, "" ); + return anchor.hash.length > 1 && + anchor.href.replace( rhash, "" ) === location.href.replace( rhash, "" ); }; $.widget( "ui.tabs", {