@@ -811,15 +811,21 @@ describe('$location', function() {
811
811
attrs = attrs ? ' ' + attrs + ' ' : '' ;
812
812
813
813
// fake the base behavior
814
- if ( ! relLink ) {
815
- if ( linkHref [ 0 ] == '/' ) {
816
- linkHref = 'http://host.com' + linkHref ;
817
- } else if ( ! linkHref . match ( / : \/ \/ / ) ) {
818
- linkHref = 'http://host.com/base/' + linkHref ;
814
+ if ( typeof linkHref === 'string' ) {
815
+ if ( ! relLink ) {
816
+ if ( linkHref [ 0 ] == '/' ) {
817
+ linkHref = 'http://host.com' + linkHref ;
818
+ } else if ( ! linkHref . match ( / : \/ \/ / ) ) {
819
+ linkHref = 'http://host.com/base/' + linkHref ;
820
+ }
819
821
}
820
822
}
821
823
822
- link = jqLite ( '<a href="' + linkHref + '"' + attrs + '>' + content + '</a>' ) [ 0 ] ;
824
+ if ( linkHref ) {
825
+ link = jqLite ( '<a href="' + linkHref + '"' + attrs + '>' + content + '</a>' ) [ 0 ] ;
826
+ } else {
827
+ link = jqLite ( '<a ' + attrs + '>' + content + '</a>' ) [ 0 ] ;
828
+ }
823
829
824
830
$provide . value ( '$sniffer' , { history : supportHist } ) ;
825
831
$locationProvider . html5Mode ( html5Mode ) ;
@@ -934,6 +940,20 @@ describe('$location', function() {
934
940
} ) ;
935
941
936
942
943
+ // Regression (gh-7721)
944
+ it ( 'should not throw when clicking anchor with no href attribute when history enabled on old browser' , function ( ) {
945
+ configureService ( null , true , false ) ;
946
+ inject (
947
+ initBrowser ( ) ,
948
+ initLocation ( ) ,
949
+ function ( $browser ) {
950
+ browserTrigger ( link , 'click' ) ;
951
+ expectNoRewrite ( $browser ) ;
952
+ }
953
+ ) ;
954
+ } ) ;
955
+
956
+
937
957
it ( 'should rewrite abs link to hashbang url when history enabled on old browser' , function ( ) {
938
958
configureService ( '/base/link?a#b' , true , false ) ;
939
959
inject (
0 commit comments