mirror of
https://github.com/jquery/jquery.git
synced 2024-11-23 02:54:22 +00:00
Revert "Offset: account for scroll when calculating position"
This reverts commit 0654711e0d
.
This commit provoked new issues: gh-2836, gh-2828.
At the meeting, we decided to revert offending commit
(in all three branches - 2.2-stable, 1.12-stable and master)
and tackle this issue in 3.x.
Fixes gh-2828
This commit is contained in:
parent
e7e80fe476
commit
a0f5c357c4
@ -142,11 +142,8 @@ jQuery.fn.extend( {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add offsetParent borders
|
// Add offsetParent borders
|
||||||
// Subtract offsetParent scroll positions
|
parentOffset.top += jQuery.css( offsetParent[ 0 ], "borderTopWidth", true );
|
||||||
parentOffset.top += jQuery.css( offsetParent[ 0 ], "borderTopWidth", true ) -
|
parentOffset.left += jQuery.css( offsetParent[ 0 ], "borderLeftWidth", true );
|
||||||
offsetParent.scrollTop();
|
|
||||||
parentOffset.left += jQuery.css( offsetParent[ 0 ], "borderLeftWidth", true ) -
|
|
||||||
offsetParent.scrollLeft();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Subtract parent offsets and element margins
|
// Subtract parent offsets and element margins
|
||||||
|
@ -412,7 +412,7 @@ testIframe( "offset/table", "table", function( $, window, document, assert ) {
|
|||||||
} );
|
} );
|
||||||
|
|
||||||
testIframe( "offset/scroll", "scroll", function( $, win, doc, assert ) {
|
testIframe( "offset/scroll", "scroll", function( $, win, doc, assert ) {
|
||||||
assert.expect( 28 );
|
assert.expect( 24 );
|
||||||
|
|
||||||
// If we're going to bastardize the tests, let's just DO it
|
// If we're going to bastardize the tests, let's just DO it
|
||||||
var ie = /msie [678]/i.test( navigator.userAgent );
|
var ie = /msie [678]/i.test( navigator.userAgent );
|
||||||
@ -495,25 +495,6 @@ testIframe( "offset/scroll", "scroll", function( $, win, doc, assert ) {
|
|||||||
assert.notEqual( $().scrollLeft( null ), null, "jQuery().scrollLeft(null) testing setter on empty jquery object" );
|
assert.notEqual( $().scrollLeft( null ), null, "jQuery().scrollLeft(null) testing setter on empty jquery object" );
|
||||||
assert.strictEqual( $().scrollTop(), null, "jQuery().scrollTop(100) testing setter on empty jquery object" );
|
assert.strictEqual( $().scrollTop(), null, "jQuery().scrollTop(100) testing setter on empty jquery object" );
|
||||||
assert.strictEqual( $().scrollLeft(), null, "jQuery().scrollLeft(100) testing setter on empty jquery object" );
|
assert.strictEqual( $().scrollLeft(), null, "jQuery().scrollLeft(100) testing setter on empty jquery object" );
|
||||||
|
|
||||||
// Tests position after parent scrolling (#15239)
|
|
||||||
$( "#scroll-1" ).scrollTop( 0 );
|
|
||||||
$( "#scroll-1" ).scrollLeft( 0 );
|
|
||||||
if ( ie ) {
|
|
||||||
assert.ok( true, "TestSwarm's iframe has hosed this test in oldIE, we surrender" );
|
|
||||||
} else {
|
|
||||||
assert.equal( $( "#scroll-1-1" ).position().top, 6, "jQuery('#scroll-1-1').position().top unaffected by parent scrolling" );
|
|
||||||
}
|
|
||||||
assert.equal( $( "#scroll-1-1" ).position().left, 6, "jQuery('#scroll-1-1').position().left unaffected by parent scrolling" );
|
|
||||||
|
|
||||||
$( "#scroll-1" ).scrollTop( 5 );
|
|
||||||
$( "#scroll-1" ).scrollLeft( 5 );
|
|
||||||
if ( ie ) {
|
|
||||||
assert.ok( true, "TestSwarm's iframe has hosed this test in oldIE, we surrender" );
|
|
||||||
} else {
|
|
||||||
assert.equal( $( "#scroll-1-1" ).position().top, 6, "jQuery('#scroll-1-1').position().top unaffected by parent scrolling" );
|
|
||||||
}
|
|
||||||
assert.equal( $( "#scroll-1-1" ).position().left, 6, "jQuery('#scroll-1-1').position().left unaffected by parent scrolling" );
|
|
||||||
} );
|
} );
|
||||||
|
|
||||||
testIframe( "offset/body", "body", function( $, window, document, assert ) {
|
testIframe( "offset/body", "body", function( $, window, document, assert ) {
|
||||||
@ -528,9 +509,9 @@ testIframe( "offset/body", "body", function( $, window, document, assert ) {
|
|||||||
QUnit.test( "chaining", function( assert ) {
|
QUnit.test( "chaining", function( assert ) {
|
||||||
assert.expect( 3 );
|
assert.expect( 3 );
|
||||||
var coords = { "top": 1, "left": 1 };
|
var coords = { "top": 1, "left": 1 };
|
||||||
equal( jQuery( "#absolute-1" ).offset( coords ).selector, "#absolute-1", "offset(coords) returns jQuery object" );
|
assert.equal( jQuery( "#absolute-1" ).offset( coords ).selector, "#absolute-1", "offset(coords) returns jQuery object" );
|
||||||
equal( jQuery( "#non-existent" ).offset( coords ).selector, "#non-existent", "offset(coords) with empty jQuery set returns jQuery object" );
|
assert.equal( jQuery( "#non-existent" ).offset( coords ).selector, "#non-existent", "offset(coords) with empty jQuery set returns jQuery object" );
|
||||||
equal( jQuery( "#absolute-1" ).offset( undefined ).selector, "#absolute-1", "offset(undefined) returns jQuery object (#5571)" );
|
assert.equal( jQuery( "#absolute-1" ).offset( undefined ).selector, "#absolute-1", "offset(undefined) returns jQuery object (#5571)" );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
QUnit.test( "offsetParent", function( assert ) {
|
QUnit.test( "offsetParent", function( assert ) {
|
||||||
|
Loading…
Reference in New Issue
Block a user