From b3a9b13a218cd90b7cf67be5d5f8ad6e76c557b0 Mon Sep 17 00:00:00 2001 From: Alexander Schmitz Date: Wed, 17 Jun 2015 11:33:06 -0400 Subject: Position: Guard against passing window to offset Starting in jQuery 3.0 this will throw an error Fixes #13493 Closes gh-1565 --- ui/position.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'ui/position.js') diff --git a/ui/position.js b/ui/position.js index 367fc3978..172503fef 100644 --- a/ui/position.js +++ b/ui/position.js @@ -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(), -- cgit v1.2.3