Skip to content

Commit 24ada82

Browse files
committed
Revert "Offset: simplify jQuery#offsetParent method"
This reverts commit 9644757.
1 parent 729c75f commit 24ada82

File tree

1 file changed

+3
-13
lines changed

1 file changed

+3
-13
lines changed

src/offset.js

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -160,24 +160,14 @@ jQuery.fn.extend( {
160160
};
161161
},
162162

163-
// This method will return documentElement in the following cases:
164-
// 1) For the element inside the iframe without offsetParent, this method will return
165-
// documentElement of the parent window
166-
// 2) For the hidden or detached element
167-
// 3) For body or html element, i.e. in case of the html node - it will return itself
168-
//
169-
// but those exceptions were never presented as a real life use-cases
170-
// and might be considered as more preferable results.
171-
//
172-
// This logic, however, is not guaranteed and can change at any point in the future
173163
offsetParent: function() {
174164
return this.map( function() {
175-
var offsetParent = this.offsetParent;
165+
var offsetParent = this.offsetParent || docElem;
176166

177-
while ( offsetParent && jQuery.css( offsetParent, "position" ) === "static" ) {
167+
while ( offsetParent && ( !jQuery.nodeName( offsetParent, "html" ) &&
168+
jQuery.css( offsetParent, "position" ) === "static" ) ) {
178169
offsetParent = offsetParent.offsetParent;
179170
}
180-
181171
return offsetParent || docElem;
182172
} );
183173
}

0 commit comments

Comments
 (0)