Skip to content

Commit b3a9b13

Browse files
committed
Position: Guard against passing window to offset
Starting in jQuery 3.0 this will throw an error Fixes #13493 Closes jquerygh-1565
1 parent bec722a commit b3a9b13

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

ui/position.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,12 +142,13 @@ $.position = {
142142
getWithinInfo: function( element ) {
143143
var withinElement = $( element || window ),
144144
isWindow = $.isWindow( withinElement[ 0 ] ),
145-
isDocument = !!withinElement[ 0 ] && withinElement[ 0 ].nodeType === 9;
145+
isDocument = !!withinElement[ 0 ] && withinElement[ 0 ].nodeType === 9,
146+
hasOffset = !isWindow && !isDocument;
146147
return {
147148
element: withinElement,
148149
isWindow: isWindow,
149150
isDocument: isDocument,
150-
offset: withinElement.offset() || { left: 0, top: 0 },
151+
offset: hasOffset ? $( element ).offset() : { left: 0, top: 0 },
151152
scrollLeft: withinElement.scrollLeft(),
152153
scrollTop: withinElement.scrollTop(),
153154
width: withinElement.outerWidth(),

0 commit comments

Comments
 (0)