From 4707e122ec8422f0a8122b3c775b8cc7feccc09d Mon Sep 17 00:00:00 2001 From: Thomas Meyer Date: Thu, 5 Sep 2013 00:13:53 +0200 Subject: [PATCH 1/2] avoid reading overflow css on document --- ui/jquery.ui.position.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ui/jquery.ui.position.js b/ui/jquery.ui.position.js index 21c3cef1b19..117858b0433 100644 --- a/ui/jquery.ui.position.js +++ b/ui/jquery.ui.position.js @@ -88,8 +88,8 @@ $.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.isDoc ? "" : within.element.css( "overflow-x" ), + overflowY = within.isWindow || within.isDoc ? "" : within.element.css( "overflow-y" ), hasOverflowX = overflowX === "scroll" || ( overflowX === "auto" && within.width < within.element[0].scrollWidth ), hasOverflowY = overflowY === "scroll" || @@ -101,10 +101,12 @@ $.position = { }, getWithinInfo: function( element ) { var withinElement = $( element || window ), - isWindow = $.isWindow( withinElement[0] ); + isWindow = $.isWindow( withinElement[0] ), + isDoc = (!!withinElement[0] && withinElement[0].nodeType === 9); return { element: withinElement, isWindow: isWindow, + isDoc: isDoc, offset: withinElement.offset() || { left: 0, top: 0 }, scrollLeft: withinElement.scrollLeft(), scrollTop: withinElement.scrollTop(), From 9564b4c88521fa451e149e173457a65baacfc87c Mon Sep 17 00:00:00 2001 From: Thomas Meyer Date: Thu, 5 Sep 2013 01:21:52 +0200 Subject: [PATCH 2/2] added unit test to check for error when positioning within document --- tests/unit/position/position_core.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/unit/position/position_core.js b/tests/unit/position/position_core.js index e03d4c11152..481e92c9046 100644 --- a/tests/unit/position/position_core.js +++ b/tests/unit/position/position_core.js @@ -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 (bug #9533)"); collisionTest({ within: "#within",