@@ -231,11 +231,26 @@ describe('$compile', function() {
231
231
232
232
describe ( 'svg namespace transcludes' , function ( ) {
233
233
// this method assumes some sort of sized SVG element is being inspected.
234
- function assertIsValidSvgCircle ( elem ) {
234
+ function assertIsValidSvgCircle ( elem , possiblyUnsizedParent ) {
235
235
expect ( isUnknownElement ( elem ) ) . toBe ( false ) ;
236
236
expect ( isSVGElement ( elem ) ) . toBe ( true ) ;
237
+
237
238
var box = elem . getBoundingClientRect ( ) ;
238
- expect ( box . width === 0 && box . height === 0 ) . toBe ( false ) ;
239
+ var hasWidthOrHeight = ( box . width !== 0 ) || ( box . height !== 0 ) ;
240
+
241
+ if ( possiblyUnsizedParent && ! hasWidthOrHeight ) {
242
+ // On MS Edge, assuming `<svg><foreignObject><svg><circle /></svg></foreignObject></svg>`,
243
+ // the nested `svg` and `circle` both have 0 width/height, despite having the appropriate
244
+ // attributes set.
245
+ // In that case, even if the `$compiler` has done its job well, the bounding `ClientRect` is
246
+ // not a reliable way to verify a valid SVG circle.
247
+ var parent = elem . parentNode ;
248
+ var parentBox = parent && parent . getBoundingClientRect ( ) ;
249
+
250
+ hasWidthOrHeight = parentBox && ( parentBox . width === 0 ) && ( parentBox . height === 0 ) ;
251
+ }
252
+
253
+ expect ( hasWidthOrHeight ) . toBe ( true ) ;
239
254
}
240
255
241
256
it ( 'should handle transcluded svg elements' , inject ( function ( $compile ) {
@@ -309,7 +324,7 @@ describe('$compile', function() {
309
324
document . body . appendChild ( element [ 0 ] ) ;
310
325
311
326
var circle = element . find ( 'circle' ) ;
312
- assertIsValidSvgCircle ( circle [ 0 ] ) ;
327
+ assertIsValidSvgCircle ( circle [ 0 ] , true ) ;
313
328
} ) ) ;
314
329
}
315
330
0 commit comments