From: Alexander Schmitz Date: Wed, 17 Jun 2015 15:33:06 +0000 (-0400) Subject: Position: Guard against passing window to offset X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=439450327626d8472edadb857cf0c71aca36b8a5;p=jquery-ui.git Position: Guard against passing window to offset Starting in jQuery 3.0 this will throw an error Fixes #13493 Closes gh-1565 (cherry picked from commit b3a9b13a218cd90b7cf67be5d5f8ad6e76c557b0) --- diff --git a/ui/position.js b/ui/position.js index 28aca6dc6..a59f0009d 100644 --- a/ui/position.js +++ b/ui/position.js @@ -114,13 +114,14 @@ $.position = { }, getWithinInfo: function( element ) { var withinElement = $( element || window ), - isWindow = $.isWindow( withinElement[0] ), - isDocument = !!withinElement[ 0 ] && withinElement[ 0 ].nodeType === 9; + isWindow = $.isWindow( withinElement[ 0 ] ), + isDocument = !!withinElement[ 0 ] && withinElement[ 0 ].nodeType === 9, + hasOffset = !isWindow && !isDocument; return { element: withinElement, isWindow: isWindow, isDocument: isDocument, - offset: withinElement.offset() || { left: 0, top: 0 }, + offset: hasOffset ? $( element ).offset() : { left: 0, top: 0 }, scrollLeft: withinElement.scrollLeft(), scrollTop: withinElement.scrollTop(),