diff --git a/src/.jshintrc b/src/.jshintrc
index 99ea5a68de32..5eda6c464777 100644
--- a/src/.jshintrc
+++ b/src/.jshintrc
@@ -124,6 +124,8 @@
"jqLiteAddNodes": false,
"jqLiteController": false,
"jqLiteInheritedData": false,
+ "jqLiteBuildFragment": false,
+ "jqLiteParseHTML": false,
"getBooleanAttrName": false,
"getAliasedAttrName": false,
"createEventHandler": false,
diff --git a/src/ng/directive/ngInclude.js b/src/ng/directive/ngInclude.js
index e78e72bc1910..7c6f0856e714 100644
--- a/src/ng/directive/ngInclude.js
+++ b/src/ng/directive/ngInclude.js
@@ -267,6 +267,18 @@ var ngIncludeFillContentDirective = ['$compile',
priority: -400,
require: 'ngInclude',
link: function(scope, $element, $attr, ctrl) {
+ if (/SVG/.test($element[0].toString())) {
+ // WebKit: https://bugs.webkit.org/show_bug.cgi?id=135698 --- SVG elements do not
+ // support innerHTML, so detect this here and try to generate the contents
+ // specially.
+ $element.empty();
+ $compile(jqLiteBuildFragment(ctrl.template, document).childNodes)(scope,
+ function namespaceAdaptedClone(clone) {
+ $element.append(clone);
+ }, undefined, undefined, $element);
+ return;
+ }
+
$element.html(ctrl.template);
$compile($element.contents())(scope);
}
diff --git a/test/ng/directive/ngIncludeSpec.js b/test/ng/directive/ngIncludeSpec.js
index 4dca3f803dc8..e3f366be6e7e 100644
--- a/test/ng/directive/ngIncludeSpec.js
+++ b/test/ng/directive/ngIncludeSpec.js
@@ -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('');
+ $httpBackend.expectGET('include.svg').respond('');
+ element = $compile('')($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('');
+ $httpBackend.expectGET('include.svg').respond('');
+ element = $compile('')($rootScope);
+ $httpBackend.flush();
+ expect(element.find('a').length).toBe(0);
+ });
+ });
+
+
describe('autoscroll', function() {
var autoScrollSpy;