@@ -853,15 +853,21 @@ describe('$location', function() {
853
853
attrs = attrs ? ' ' + attrs + ' ' : '' ;
854
854
855
855
// fake the base behavior
856
- if ( ! relLink ) {
857
- if ( linkHref [ 0 ] == '/' ) {
858
- linkHref = 'http://host.com' + linkHref ;
859
- } else if ( ! linkHref . match ( / : \/ \/ / ) ) {
860
- linkHref = 'http://host.com/base/' + linkHref ;
856
+ if ( typeof linkHref === 'string' ) {
857
+ if ( ! relLink ) {
858
+ if ( linkHref [ 0 ] == '/' ) {
859
+ linkHref = 'http://host.com' + linkHref ;
860
+ } else if ( ! linkHref . match ( / : \/ \/ / ) ) {
861
+ linkHref = 'http://host.com/base/' + linkHref ;
862
+ }
861
863
}
862
864
}
863
865
864
- link = jqLite ( '<a href="' + linkHref + '"' + attrs + '>' + content + '</a>' ) [ 0 ] ;
866
+ if ( linkHref ) {
867
+ link = jqLite ( '<a href="' + linkHref + '"' + attrs + '>' + content + '</a>' ) [ 0 ] ;
868
+ } else {
869
+ link = jqLite ( '<a ' + attrs + '>' + content + '</a>' ) [ 0 ] ;
870
+ }
865
871
866
872
$provide . value ( '$sniffer' , { history : supportHist } ) ;
867
873
$locationProvider . html5Mode ( html5Mode ) ;
@@ -976,6 +982,20 @@ describe('$location', function() {
976
982
} ) ;
977
983
978
984
985
+ // Regression (gh-7721)
986
+ it ( 'should not throw when clicking anchor with no href attribute when history enabled on old browser' , function ( ) {
987
+ configureService ( null , true , false ) ;
988
+ inject (
989
+ initBrowser ( ) ,
990
+ initLocation ( ) ,
991
+ function ( $browser ) {
992
+ browserTrigger ( link , 'click' ) ;
993
+ expectNoRewrite ( $browser ) ;
994
+ }
995
+ ) ;
996
+ } ) ;
997
+
998
+
979
999
it ( 'should rewrite abs link to hashbang url when history enabled on old browser' , function ( ) {
980
1000
configureService ( '/base/link?a#b' , true , false ) ;
981
1001
inject (
0 commit comments