aboutsummaryrefslogtreecommitdiffstats
path: root/src/offset.js
diff options
context:
space:
mode:
authorLiam James <liam@minimaximize.com>2024-04-19 23:47:52 +1000
committerGitHub <noreply@github.com>2024-04-19 15:47:52 +0200
commit556eaf4a193287c306d163635cbb5f5c95a22a84 (patch)
treed8f8c91307f28c32db5a5c0d9b5ba6ce0a833a4c /src/offset.js
parentdf1df9503afad78bec3ba5217f9a9efce49fe634 (diff)
downloadjquery-556eaf4a193287c306d163635cbb5f5c95a22a84.tar.gz
jquery-556eaf4a193287c306d163635cbb5f5c95a22a84.zip
Offset: Increase search depth when finding the 'real' offset parent
Changes: * Increase search depth when finding for the real offset parent * Ignore offset for statically positioned offset parent * Add tests for the position of an element in a table Closes gh-4861
Diffstat (limited to 'src/offset.js')
-rw-r--r--src/offset.js7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/offset.js b/src/offset.js
index ca27ca5c7..65dab2bd2 100644
--- a/src/offset.js
+++ b/src/offset.js
@@ -121,12 +121,13 @@ jQuery.fn.extend( {
doc = elem.ownerDocument;
offsetParent = elem.offsetParent || doc.documentElement;
while ( offsetParent &&
- ( offsetParent === doc.body || offsetParent === doc.documentElement ) &&
+ offsetParent !== doc.documentElement &&
jQuery.css( offsetParent, "position" ) === "static" ) {
- offsetParent = offsetParent.parentNode;
+ offsetParent = offsetParent.offsetParent || doc.documentElement;
}
- if ( offsetParent && offsetParent !== elem && offsetParent.nodeType === 1 ) {
+ if ( offsetParent && offsetParent !== elem && offsetParent.nodeType === 1 &&
+ jQuery.css( offsetParent, "position" ) !== "static" ) {
// Incorporate borders into its offset, since they are outside its content origin
parentOffset = jQuery( offsetParent ).offset();