Permalink
Browse files

Position: Guard against passing window to offset

Starting in jQuery 3.0 this will throw an error

Fixes #13493
Closes gh-1565
  • Loading branch information...
arschmitz committed Jun 17, 2015
1 parent bec722a commit b3a9b13a218cd90b7cf67be5d5f8ad6e76c557b0
Showing with 3 additions and 2 deletions.
  1. +3 −2 ui/position.js
View
@@ -142,12 +142,13 @@ $.position = {
getWithinInfo: function( element ) {
var withinElement = $( element || window ),
isWindow = $.isWindow( withinElement[ 0 ] ),
- isDocument = !!withinElement[ 0 ] && withinElement[ 0 ].nodeType === 9;
+ 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(),
width: withinElement.outerWidth(),

0 comments on commit b3a9b13

Please sign in to comment.