]> source.dussan.org Git - jquery-ui.git/commitdiff
Position: Avoid reading overflow css on documents
authorThomas Meyer <meyertee@gmail.com>
Wed, 4 Sep 2013 22:13:53 +0000 (00:13 +0200)
committerScott González <scott.gonzalez@gmail.com>
Wed, 15 Jan 2014 10:19:26 +0000 (05:19 -0500)
Fixes #9533
Closes gh-1072
(cherry picked from commit 1bbbcc723c489d7ef7d72bb62564b8f07805c41c)

tests/unit/position/position_core.js
ui/jquery.ui.position.js

index e03d4c1115298f13b89c985b768fd44daf6b25c5..5b1872af9838f542636a120091ab3f9ed9af6676 100644 (file)
@@ -575,7 +575,14 @@ test( "collision: flip, with margin", function() {
 });
 
 test( "within", function() {
-       expect( 6 );
+       expect( 7 );
+
+       collisionTest({
+               within: document
+       }, {
+               top: 10,
+               left: 10
+       }, "within document" );
 
        collisionTest({
                within: "#within",
index 21c3cef1b19a46b3ddba23122c1389902a6f1d53..dc0ed0ee40b60b3ad7f980eaae1bc410eb869677 100644 (file)
@@ -88,8 +88,10 @@ $.position = {
                return (cachedScrollbarWidth = w1 - w2);
        },
        getScrollInfo: function( within ) {
-               var overflowX = within.isWindow ? "" : within.element.css( "overflow-x" ),
-                       overflowY = within.isWindow ? "" : within.element.css( "overflow-y" ),
+               var overflowX = within.isWindow || within.isDocument ? "" :
+                               within.element.css( "overflow-x" ),
+                       overflowY = within.isWindow || within.isDocument ? "" :
+                               within.element.css( "overflow-y" ),
                        hasOverflowX = overflowX === "scroll" ||
                                ( overflowX === "auto" && within.width < within.element[0].scrollWidth ),
                        hasOverflowY = overflowY === "scroll" ||
@@ -101,10 +103,12 @@ $.position = {
        },
        getWithinInfo: function( element ) {
                var withinElement = $( element || window ),
-                       isWindow = $.isWindow( withinElement[0] );
+                       isWindow = $.isWindow( withinElement[0] ),
+                       isDocument = !!withinElement[ 0 ] && withinElement[ 0 ].nodeType === 9;
                return {
                        element: withinElement,
                        isWindow: isWindow,
+                       isDocument: isDocument,
                        offset: withinElement.offset() || { left: 0, top: 0 },
                        scrollLeft: withinElement.scrollLeft(),
                        scrollTop: withinElement.scrollTop(),