mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-04-24 03:55:49 +08:00
feat(ngHref): bind ng-href to xlink:href for SVGAElement
This change makes the ngHref directive useful for SVGAElements by having it bind to the xlink:href attribute rather than the href attribute. Closes #5904
This commit is contained in:
@@ -251,4 +251,28 @@ describe('ngHref', function() {
|
||||
$rootScope.$digest();
|
||||
expect(element.attr('href')).toEqual('http://server');
|
||||
}));
|
||||
|
||||
if (isDefined(window.SVGElement)) {
|
||||
describe('SVGAElement', function() {
|
||||
it('should interpolate the expression and bind to xlink:href', inject(function($compile, $rootScope) {
|
||||
element = $compile('<svg><a ng-href="some/{{id}}"></a></svg>')($rootScope);
|
||||
var child = element.children('a');
|
||||
$rootScope.$digest();
|
||||
expect(child.attr('xlink:href')).toEqual('some/');
|
||||
|
||||
$rootScope.$apply(function() {
|
||||
$rootScope.id = 1;
|
||||
});
|
||||
expect(child.attr('xlink:href')).toEqual('some/1');
|
||||
}));
|
||||
|
||||
|
||||
it('should bind xlink:href even if no interpolation', inject(function($rootScope, $compile) {
|
||||
element = $compile('<svg><a ng-href="http://server"></a></svg>')($rootScope);
|
||||
var child = element.children('a');
|
||||
$rootScope.$digest();
|
||||
expect(child.attr('xlink:href')).toEqual('http://server');
|
||||
}));
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user