From 25e8620da9c6e245516d8ac1b0f9ddc896838883 Mon Sep 17 00:00:00 2001 From: Timmy Willison Date: Tue, 16 Jun 2015 11:21:58 -0400 Subject: [PATCH] Offset: return before getBoundingClientRect to avoid error in IE8-11 --- src/offset.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/offset.js b/src/offset.js index d184016e9..bad91e779 100644 --- a/src/offset.js +++ b/src/offset.js @@ -95,10 +95,17 @@ jQuery.fn.extend({ return; } + // Support: IE<=11+ + // Running getBoundingClientRect on a + // disconnected node in IE throws an error + if ( !elem.getClientRects().length ) { + return { top: 0, left: 0 }; + } + rect = elem.getBoundingClientRect(); - // Make sure element is not hidden (display: none) or disconnected - if ( rect.width || rect.height || elem.getClientRects().length ) { + // Make sure element is not hidden (display: none) + if ( rect.width || rect.height ) { doc = elem.ownerDocument; win = getWindow( doc ); docElem = doc.documentElement; -- 2.39.5