From c2404d30e90450f806e5782738a24ddda774f3bf Mon Sep 17 00:00:00 2001 From: Chris Rebert Date: Wed, 20 Jul 2016 17:21:56 -0700 Subject: [PATCH] Avoid using $.offset() on SVGs since it gives incorrect results in jQuery 3; fixes #20280 (#20313) Refs https://github.com/jquery/jquery/issues/3137 [skip validator] --- js/tooltip.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/js/tooltip.js b/js/tooltip.js index 943002199e..f92731b3ea 100644 --- a/js/tooltip.js +++ b/js/tooltip.js @@ -364,7 +364,10 @@ // width and height are missing in IE8, so compute them manually; see https://github.com/twbs/bootstrap/issues/14093 elRect = $.extend({}, elRect, { width: elRect.right - elRect.left, height: elRect.bottom - elRect.top }) } - var elOffset = isBody ? { top: 0, left: 0 } : $element.offset() + var isSvg = window.SVGElement && el instanceof window.SVGElement + // Avoid using $.offset() on SVGs since it gives incorrect results in jQuery 3. + // See https://github.com/twbs/bootstrap/issues/20280 + var elOffset = isBody ? { top: 0, left: 0 } : (isSvg ? null : $element.offset()) var scroll = { scroll: isBody ? document.documentElement.scrollTop || document.body.scrollTop : $element.scrollTop() } var outerDims = isBody ? { width: $(window).width(), height: $(window).height() } : null