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

Commit 70a515d

Browse files
committed
Test for SVG-ness in ngIncludeFillContent linkFn
1 parent f2f8d42 commit 70a515d

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

src/ng/directive/ngInclude.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -267,9 +267,21 @@ var ngIncludeFillContentDirective = ['$compile',
267267
priority: -400,
268268
require: 'ngInclude',
269269
link: function(scope, $element, $attr, ctrl) {
270-
$element.empty();
271-
$element.append(jqLite(jqLiteBuildFragment(ctrl.template, document).childNodes));
272-
$compile($element.contents())(scope, undefined, null, null, $element);
270+
var isSVGElement = /SVG/.test($element[0].toString());
271+
272+
if (isSVGElement) {
273+
// WebKit: https://bugs.webkit.org/show_bug.cgi?id=135698 --- SVG elements do not
274+
// support innerHTML, so detect this here and try to generate the contents
275+
// specially.
276+
$element.empty();
277+
$element.append(jqLiteBuildFragment(ctrl.template, document).childNodes);
278+
$compile($element.contents())(scope, function namespaceAdaptedClone(clone) {
279+
$element.append(clone);
280+
}, undefined, undefined, $element);
281+
return;
282+
}
283+
$element.html(ctrl.template);
284+
$compile($element.contents())(scope);
273285
}
274286
};
275287
}];

0 commit comments

Comments
 (0)