Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 2a8da48

Browse files
committed
WIP --- Final version of fix
1 parent 70a515d commit 2a8da48

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

src/ng/directive/ngInclude.js

+4-6
Original file line numberDiff line numberDiff line change
@@ -267,19 +267,17 @@ var ngIncludeFillContentDirective = ['$compile',
267267
priority: -400,
268268
require: 'ngInclude',
269269
link: function(scope, $element, $attr, ctrl) {
270-
var isSVGElement = /SVG/.test($element[0].toString());
271-
272-
if (isSVGElement) {
270+
if (/SVG/.test($element[0].toString()) && nodeName_($element[0]) !== 'foreignobject') {
273271
// WebKit: https://bugs.webkit.org/show_bug.cgi?id=135698 --- SVG elements do not
274272
// support innerHTML, so detect this here and try to generate the contents
275273
// specially.
276-
$element.empty();
277-
$element.append(jqLiteBuildFragment(ctrl.template, document).childNodes);
278-
$compile($element.contents())(scope, function namespaceAdaptedClone(clone) {
274+
$compile(jqLiteBuildFragment(ctrl.template, document).childNodes)(scope,
275+
function namespaceAdaptedClone(clone) {
279276
$element.append(clone);
280277
}, undefined, undefined, $element);
281278
return;
282279
}
280+
283281
$element.html(ctrl.template);
284282
$compile($element.contents())(scope);
285283
}

test/ng/directive/ngIncludeSpec.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -603,11 +603,11 @@ describe('ngInclude and transcludes', function() {
603603
});
604604
inject(function($compile, $rootScope, $httpBackend) {
605605
$httpBackend.expectGET('my-rect.html').respond('<g ng-include="\'include.svg\'"></g>');
606-
$httpBackend.expectGET('include.svg').respond('<rect></rect>');
606+
$httpBackend.expectGET('include.svg').respond('<rect></rect><rect></rect>');
607607
element = $compile('<svg><test></test></svg>')($rootScope);
608608
$httpBackend.flush();
609609
var child = element.find('rect');
610-
expect(child.length).toBe(1);
610+
expect(child.length).toBe(2);
611611
expect(child[0] instanceof SVGRectElement).toBe(true);
612612
});
613613
});

0 commit comments

Comments
 (0)