This repository was archived by the owner on Apr 12, 2024. It is now read-only.
File tree 2 files changed +6
-8
lines changed
2 files changed +6
-8
lines changed Original file line number Diff line number Diff line change @@ -267,19 +267,17 @@ var ngIncludeFillContentDirective = ['$compile',
267
267
priority : - 400 ,
268
268
require : 'ngInclude' ,
269
269
link : function ( scope , $element , $attr , ctrl ) {
270
- var isSVGElement = / S V G / . test ( $element [ 0 ] . toString ( ) ) ;
271
-
272
- if ( isSVGElement ) {
270
+ if ( / S V G / . test ( $element [ 0 ] . toString ( ) ) && nodeName_ ( $element [ 0 ] ) !== 'foreignobject' ) {
273
271
// WebKit: https://bugs.webkit.org/show_bug.cgi?id=135698 --- SVG elements do not
274
272
// support innerHTML, so detect this here and try to generate the contents
275
273
// 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 ) {
279
276
$element . append ( clone ) ;
280
277
} , undefined , undefined , $element ) ;
281
278
return ;
282
279
}
280
+
283
281
$element . html ( ctrl . template ) ;
284
282
$compile ( $element . contents ( ) ) ( scope ) ;
285
283
}
Original file line number Diff line number Diff line change @@ -603,11 +603,11 @@ describe('ngInclude and transcludes', function() {
603
603
} ) ;
604
604
inject ( function ( $compile , $rootScope , $httpBackend ) {
605
605
$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> ' ) ;
607
607
element = $compile ( '<svg><test></test></svg>' ) ( $rootScope ) ;
608
608
$httpBackend . flush ( ) ;
609
609
var child = element . find ( 'rect' ) ;
610
- expect ( child . length ) . toBe ( 1 ) ;
610
+ expect ( child . length ) . toBe ( 2 ) ;
611
611
expect ( child [ 0 ] instanceof SVGRectElement ) . toBe ( true ) ;
612
612
} ) ;
613
613
} ) ;
You can’t perform that action at this time.
0 commit comments