Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit556eaf4

Browse files
authored
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 tableClosesgh-4861
1 parentdf1df95 commit556eaf4

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

‎src/offset.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,13 @@ jQuery.fn.extend( {
121121
doc=elem.ownerDocument;
122122
offsetParent=elem.offsetParent||doc.documentElement;
123123
while(offsetParent&&
124-
(offsetParent===doc.body||offsetParent===doc.documentElement)&&
124+
offsetParent!==doc.documentElement&&
125125
jQuery.css(offsetParent,"position")==="static"){
126126

127-
offsetParent=offsetParent.parentNode;
127+
offsetParent=offsetParent.offsetParent||doc.documentElement;
128128
}
129-
if(offsetParent&&offsetParent!==elem&&offsetParent.nodeType===1){
129+
if(offsetParent&&offsetParent!==elem&&offsetParent.nodeType===1&&
130+
jQuery.css(offsetParent,"position")!=="static"){
130131

131132
// Incorporate borders into its offset, since they are outside its content origin
132133
parentOffset=jQuery(offsetParent).offset();

‎test/unit/offset.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,13 +436,16 @@ testIframe( "fixed", "offset/fixed.html", function( assert, $, window ) {
436436
});
437437

438438
testIframe("table","offset/table.html",function(assert,$){
439-
assert.expect(4);
439+
assert.expect(6);
440440

441441
assert.equal($("#table-1").offset().top,6,"jQuery('#table-1').offset().top");
442442
assert.equal($("#table-1").offset().left,6,"jQuery('#table-1').offset().left");
443443

444444
assert.equal($("#th-1").offset().top,10,"jQuery('#th-1').offset().top");
445445
assert.equal($("#th-1").offset().left,10,"jQuery('#th-1').offset().left");
446+
447+
assert.equal($("#th-1").position().top,10,"jQuery('#th-1').position().top");
448+
assert.equal($("#th-1").position().left,10,"jQuery('#th-1').position().left");
446449
});
447450

448451
testIframe("scroll","offset/scroll.html",function(assert,$,win){

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp