@@ -811,15 +811,21 @@ describe('$location', function() {
811811 attrs = attrs ? ' ' + attrs + ' ' : '' ;
812812
813813 // 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+ }
819821 }
820822 }
821823
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+ }
823829
824830 $provide . value ( '$sniffer' , { history : supportHist } ) ;
825831 $locationProvider . html5Mode ( html5Mode ) ;
@@ -934,6 +940,20 @@ describe('$location', function() {
934940 } ) ;
935941
936942
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+
937957 it ( 'should rewrite abs link to hashbang url when history enabled on old browser' , function ( ) {
938958 configureService ( '/base/link?a#b' , true , false ) ;
939959 inject (
0 commit comments