fix(ngInclude): correctly add svg-namespaced template content

It is now possible for ngInclude to correctly load SVG content in non-blink browsers, which do not
sort out the namespace when parsing HTML.

Closes #7538
Closes #8981
Closes #8997
This commit is contained in:
Caitlin Potter
2014-09-08 14:39:41 -04:00
parent 719f42e949
commit 6639ca9d6b
2 changed files with 52 additions and 0 deletions

View File

@@ -362,6 +362,46 @@ describe('ngInclude', function() {
}));
it('should construct SVG template elements with correct namespace', function() {
if (!window.SVGRectElement) return;
module(function($compileProvider) {
$compileProvider.directive('test', valueFn({
templateNamespace: 'svg',
templateUrl: 'my-rect.html',
replace: true
}));
});
inject(function($compile, $rootScope, $httpBackend) {
$httpBackend.expectGET('my-rect.html').respond('<g ng-include="\'include.svg\'"></g>');
$httpBackend.expectGET('include.svg').respond('<rect></rect><rect></rect>');
element = $compile('<svg><test></test></svg>')($rootScope);
$httpBackend.flush();
var child = element.find('rect');
expect(child.length).toBe(2);
expect(child[0] instanceof SVGRectElement).toBe(true);
});
});
it('should compile only the template content of an SVG template', function() {
if (!window.SVGRectElement) return;
module(function($compileProvider) {
$compileProvider.directive('test', valueFn({
templateNamespace: 'svg',
templateUrl: 'my-rect.html',
replace: true
}));
});
inject(function($compile, $rootScope, $httpBackend) {
$httpBackend.expectGET('my-rect.html').respond('<g ng-include="\'include.svg\'"><a></a></g>');
$httpBackend.expectGET('include.svg').respond('<rect></rect><rect></rect>');
element = $compile('<svg><test></test></svg>')($rootScope);
$httpBackend.flush();
expect(element.find('a').length).toBe(0);
});
});
describe('autoscroll', function() {
var autoScrollSpy;