This repository was archived by the owner on Oct 8, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +25
-3
lines changed
tests/integration/navigation Expand file tree Collapse file tree 3 files changed +25
-3
lines changed Original file line number Diff line number Diff line change @@ -364,9 +364,10 @@ define( [
364364 // lists and select dialogs, just write a hash in the link they
365365 // create. This means the actual URL path is based on whatever
366366 // the current value of the base tag is at the time this code
367- // is called. For now we are just assuming that any url with a
368- // hash in it is an application page reference.
369- if ( href . search ( "#" ) !== - 1 ) {
367+ // is called.
368+ if ( href . search ( "#" ) !== - 1 &&
369+ ! ( $ . mobile . path . isExternal ( href ) && $ . mobile . path . isAbsoluteUrl ( href ) ) ) {
370+
370371 href = href . replace ( / [ ^ # ] * # / , "" ) ;
371372 if ( ! href ) {
372373 //link was an empty hash meant purely
Original file line number Diff line number Diff line change 3030 < div id ="qunit "> </ div >
3131
3232 < div id ="harmless-default-page " data-nstest-role ="page " class ="first-page ">
33+ < a id ="goToGoogle " href ="http://www.google.com/#abc "> Go to Google</ a >
3334 </ div >
3435
3536 < div id ="foo " data-nstest-role ="page " class ="foo-class ">
Original file line number Diff line number Diff line change @@ -16,6 +16,26 @@ $.testHelper.delayStart();
1616 $ . testHelper . openPage ( "#" + location . pathname + location . search ) ;
1717 } ;
1818
19+ test ( "Absolute link with hash works" , function ( ) {
20+ var defaultIsPrevented ,
21+ theLink = $ ( "#goToGoogle" ) ,
22+ theClickHandler = function ( event ) {
23+ defaultIsPrevented = ! ! event . isDefaultPrevented ( ) ;
24+ if ( event . target === theLink [ 0 ] ) {
25+ event . preventDefault ( ) ;
26+ }
27+ } ;
28+
29+ $ . mobile . document . one ( "click" , theClickHandler ) ;
30+
31+ $ ( "#goToGoogle" ) . click ( ) ;
32+
33+ $ . mobile . document . off ( "click" , theClickHandler ) ;
34+
35+ deepEqual ( defaultIsPrevented , false ,
36+ "Default is not prevented when clicking on external link with hash" ) ;
37+ } ) ;
38+
1939 module ( 'jquery.mobile.navigation.js' , {
2040 setup : function ( ) {
2141 $ . mobile . navigate . history . stack = [ ] ;
You can’t perform that action at this time.
0 commit comments