Skip to content

Commit c2404d3

Browse files
authored
Avoid using $.offset() on SVGs since it gives incorrect results in jQuery 3; fixes twbs#20280 (twbs#20313)
Refs jquery/jquery#3137 [skip validator]
1 parent d3cbb8e commit c2404d3

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

js/tooltip.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,10 @@
364364
// width and height are missing in IE8, so compute them manually; see https://github.com/twbs/bootstrap/issues/14093
365365
elRect = $.extend({}, elRect, { width: elRect.right - elRect.left, height: elRect.bottom - elRect.top })
366366
}
367-
var elOffset = isBody ? { top: 0, left: 0 } : $element.offset()
367+
var isSvg = window.SVGElement && el instanceof window.SVGElement
368+
// Avoid using $.offset() on SVGs since it gives incorrect results in jQuery 3.
369+
// See https://github.com/twbs/bootstrap/issues/20280
370+
var elOffset = isBody ? { top: 0, left: 0 } : (isSvg ? null : $element.offset())
368371
var scroll = { scroll: isBody ? document.documentElement.scrollTop || document.body.scrollTop : $element.scrollTop() }
369372
var outerDims = isBody ? { width: $(window).width(), height: $(window).height() } : null
370373

0 commit comments

Comments
 (0)