Skip to content

Commit 1bbbcc7

Browse files
meyerteescottgonzalez
authored andcommitted
Position: Avoid reading overflow css on documents
Fixes #9533 Closes gh-1072
1 parent 8f267ee commit 1bbbcc7

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

tests/unit/position/position_core.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,14 @@ test( "collision: flip, with margin", function() {
575575
});
576576

577577
test( "within", function() {
578-
expect( 6 );
578+
expect( 7 );
579+
580+
collisionTest({
581+
within: document
582+
}, {
583+
top: 10,
584+
left: 10
585+
}, "within document" );
579586

580587
collisionTest({
581588
within: "#within",

ui/jquery.ui.position.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,10 @@ $.position = {
8989
return (cachedScrollbarWidth = w1 - w2);
9090
},
9191
getScrollInfo: function( within ) {
92-
var overflowX = within.isWindow ? "" : within.element.css( "overflow-x" ),
93-
overflowY = within.isWindow ? "" : within.element.css( "overflow-y" ),
92+
var overflowX = within.isWindow || within.isDocument ? "" :
93+
within.element.css( "overflow-x" ),
94+
overflowY = within.isWindow || within.isDocument ? "" :
95+
within.element.css( "overflow-y" ),
9496
hasOverflowX = overflowX === "scroll" ||
9597
( overflowX === "auto" && within.width < within.element[0].scrollWidth ),
9698
hasOverflowY = overflowY === "scroll" ||
@@ -102,10 +104,12 @@ $.position = {
102104
},
103105
getWithinInfo: function( element ) {
104106
var withinElement = $( element || window ),
105-
isWindow = $.isWindow( withinElement[0] );
107+
isWindow = $.isWindow( withinElement[0] ),
108+
isDocument = !!withinElement[ 0 ] && withinElement[ 0 ].nodeType === 9;
106109
return {
107110
element: withinElement,
108111
isWindow: isWindow,
112+
isDocument: isDocument,
109113
offset: withinElement.offset() || { left: 0, top: 0 },
110114
scrollLeft: withinElement.scrollLeft(),
111115
scrollTop: withinElement.scrollTop(),

0 commit comments

Comments
 (0)