links with no href attribute will not throw an error when clicked. Fixes #932

This commit is contained in:
scottjehl 2011-02-01 01:01:41 -05:00
parent e00f007792
commit a5c8f86d10
2 changed files with 24 additions and 4 deletions

View file

@ -599,8 +599,12 @@
$( "a" ).live( "click", function(event) {
var $this = $(this),
//get href, if defined, otherwise fall to null #
href = $this.attr( "href" ) || "#",
//get href, remove same-domain protocol and host
url = path.clean( $this.attr( "href" ) ),
url = path.clean( href ),
//rel set to external
isRelExternal = $this.is( "[rel='external']" ),

View file

@ -39,6 +39,22 @@
});
asyncTest( "anchors with no href attribute will do nothing when clicked", function(){
var fired = false;
$(window).bind("hashchange.temp", function(){
fired = true;
});
$( "<a>test</a>" ).appendTo( $.mobile.pageContainer ).click();
setTimeout(function(){
start();
same(fired, false, "hash shouldn't change after click");
$(window).unbind("hashchange.temp");
}, 500);
});
@ -172,10 +188,10 @@
testListening( $.mobile.hashListeningEnabled );
});
asynctest( "changepage will only run once when a new page is visited", function(){
asyncTest( "changepage will only run once when a new page is visited", function(){
var called = 0;
$.mobile.changePage = function(){
changePageFn( arguments );
$.mobile.changePage = function(a,b,c,d,e){
changePageFn( a,b,c,d,e );
called ++;
};