mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-04-23 03:30:02 +08:00
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:
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user