Skip to content
This repository was archived by the owner on Oct 8, 2021. It is now read-only.

Commit 35eea35

Browse files
author
Gabriel Schulhof
committed
[navigation] vclick handler: Do not add active class if already added
This helps avoid setting an element which has the active class added by hand as $activeClickedLink, which will cause that element to lose its active class if another link is activated.
1 parent 6404d38 commit 35eea35

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

js/jquery.mobile.navigation.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1325,7 +1325,7 @@ define( [
13251325
return;
13261326
}
13271327

1328-
var link = findClosestLink( event.target );
1328+
var link = findClosestLink( event.target ), $btn;
13291329

13301330
// split from the previous return logic to avoid find closest where possible
13311331
// TODO teach $.mobile.hijackable to operate on raw dom elements so the link wrapping
@@ -1335,9 +1335,10 @@ define( [
13351335
}
13361336

13371337
if ( link ) {
1338-
if ( path.parseUrl( link.getAttribute( "href" ) || "#" ).hash !== "#" ) {
1338+
$btn = $( link ).closest( ".ui-btn" ).not( ".ui-disabled" );
1339+
if ( path.parseUrl( link.getAttribute( "href" ) || "#" ).hash !== "#" && !$btn.hasClass( $.mobile.activeBtnClass ) ) {
13391340
removeActiveLinkClass( true );
1340-
$activeClickedLink = $( link ).closest( ".ui-btn" ).not( ".ui-disabled" );
1341+
$activeClickedLink = $btn;
13411342
$activeClickedLink.addClass( $.mobile.activeBtnClass );
13421343
}
13431344
}

0 commit comments

Comments
 (0)