From: Timmy Willison Date: Wed, 6 Jan 2016 19:31:46 +0000 (-0500) Subject: Revert "Offset: simplify jQuery#offsetParent method" X-Git-Tag: 1.12.0~16 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=24ada82ce803f68d65d47218800208844eadab68;p=jquery.git Revert "Offset: simplify jQuery#offsetParent method" This reverts commit 96447575c23f7b313091750ed84cec05db3a25c6. --- diff --git a/src/offset.js b/src/offset.js index 9160f7e88..882d85893 100644 --- a/src/offset.js +++ b/src/offset.js @@ -160,24 +160,14 @@ jQuery.fn.extend( { }; }, - // This method will return documentElement in the following cases: - // 1) For the element inside the iframe without offsetParent, this method will return - // documentElement of the parent window - // 2) For the hidden or detached element - // 3) For body or html element, i.e. in case of the html node - it will return itself - // - // but those exceptions were never presented as a real life use-cases - // and might be considered as more preferable results. - // - // This logic, however, is not guaranteed and can change at any point in the future offsetParent: function() { return this.map( function() { - var offsetParent = this.offsetParent; + var offsetParent = this.offsetParent || docElem; - while ( offsetParent && jQuery.css( offsetParent, "position" ) === "static" ) { + while ( offsetParent && ( !jQuery.nodeName( offsetParent, "html" ) && + jQuery.css( offsetParent, "position" ) === "static" ) ) { offsetParent = offsetParent.offsetParent; } - return offsetParent || docElem; } ); }