@@ -299,25 +299,44 @@ describe('ngHref', function() {
299299
300300 if ( isDefined ( window . SVGElement ) ) {
301301 describe ( 'SVGAElement' , function ( ) {
302- it ( 'should interpolate the expression and bind to xlink:href' , inject ( function ( $compile , $rootScope ) {
302+ it ( 'should interpolate the expression and bind to xlink:href and href ' , inject ( function ( $compile , $rootScope ) {
303303 element = $compile ( '<svg><a ng-href="some/{{id}}"></a></svg>' ) ( $rootScope ) ;
304304 var child = element . children ( 'a' ) ;
305305 $rootScope . $digest ( ) ;
306306 expect ( child . attr ( 'xlink:href' ) ) . toEqual ( 'some/' ) ;
307+ expect ( child . attr ( 'href' ) ) . toEqual ( 'some/' ) ;
307308
308309 $rootScope . $apply ( function ( ) {
309310 $rootScope . id = 1 ;
310311 } ) ;
311312 expect ( child . attr ( 'xlink:href' ) ) . toEqual ( 'some/1' ) ;
313+ expect ( child . attr ( 'href' ) ) . toEqual ( 'some/1' ) ;
312314 } ) ) ;
313315
314316
315- it ( 'should bind xlink:href even if no interpolation' , inject ( function ( $rootScope , $compile ) {
317+ it ( 'should bind xlink:href and href even if no interpolation' , inject ( function ( $rootScope , $compile ) {
316318 element = $compile ( '<svg><a ng-href="http://server"></a></svg>' ) ( $rootScope ) ;
317319 var child = element . children ( 'a' ) ;
318320 $rootScope . $digest ( ) ;
319321 expect ( child . attr ( 'xlink:href' ) ) . toEqual ( 'http://server' ) ;
322+ expect ( child . attr ( 'href' ) ) . toEqual ( 'http://server' ) ;
320323 } ) ) ;
324+
325+ they ( 'should set xlink:href and href to null when ng-href value is $prop' , [ '' , 0 , null , false , undefined ] ,
326+ function ( value ) {
327+ var $compile , $rootScope ;
328+ inject ( function ( _$compile_ , _$rootScope_ ) {
329+ $compile = _$compile_ ;
330+ $rootScope = _$rootScope_ ;
331+ } ) ;
332+
333+ $rootScope . url = value ;
334+ element = $compile ( '<svg><a ng-href="{{url}}"></a></svg>' ) ( $rootScope ) ;
335+ var child = element . children ( 'a' ) ;
336+ expect ( child . attr ( 'xlink:href' ) ) . toBeUndefined ( ) ;
337+ expect ( child . attr ( 'href' ) ) . toBeUndefined ( ) ;
338+ }
339+ ) ;
321340 } ) ;
322341 }
323342} ) ;
0 commit comments