aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOleg Gaidarenko <markelog@gmail.com>2016-02-08 23:39:43 +0300
committerOleg Gaidarenko <markelog@gmail.com>2016-02-09 00:10:02 +0300
commita0f5c357c4b256b03acdc57d5319ebfe4f25a69a (patch)
treed1d54ecfa1d81d44d55e45784230466e8b413fd8
parente7e80fe476478ebcb6f1e1e25f8edf96f5a14c9a (diff)
downloadjquery-a0f5c357c4b256b03acdc57d5319ebfe4f25a69a.tar.gz
jquery-a0f5c357c4b256b03acdc57d5319ebfe4f25a69a.zip
Revert "Offset: account for scroll when calculating position"
This reverts commit 0654711e0d929187249ca9507ae5881c72947843. 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
-rw-r--r--src/offset.js7
-rw-r--r--test/unit/offset.js27
2 files changed, 6 insertions, 28 deletions
diff --git a/src/offset.js b/src/offset.js
index 43fb0155a..3e5bb97b5 100644
--- a/src/offset.js
+++ b/src/offset.js
@@ -142,11 +142,8 @@ jQuery.fn.extend( {
}
// Add offsetParent borders
- // Subtract offsetParent scroll positions
- parentOffset.top += jQuery.css( offsetParent[ 0 ], "borderTopWidth", true ) -
- offsetParent.scrollTop();
- parentOffset.left += jQuery.css( offsetParent[ 0 ], "borderLeftWidth", true ) -
- offsetParent.scrollLeft();
+ parentOffset.top += jQuery.css( offsetParent[ 0 ], "borderTopWidth", true );
+ parentOffset.left += jQuery.css( offsetParent[ 0 ], "borderLeftWidth", true );
}
// Subtract parent offsets and element margins
diff --git a/test/unit/offset.js b/test/unit/offset.js
index b8e0c6977..15d3895c3 100644
--- a/test/unit/offset.js
+++ b/test/unit/offset.js
@@ -412,7 +412,7 @@ testIframe( "offset/table", "table", function( $, window, document, 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
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.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" );
-
- // 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 ) {
@@ -528,9 +509,9 @@ testIframe( "offset/body", "body", function( $, window, document, assert ) {
QUnit.test( "chaining", function( assert ) {
assert.expect( 3 );
var coords = { "top": 1, "left": 1 };
- 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" );
- equal( jQuery( "#absolute-1" ).offset( undefined ).selector, "#absolute-1", "offset(undefined) returns jQuery object (#5571)" );
+ assert.equal( jQuery( "#absolute-1" ).offset( coords ).selector, "#absolute-1", "offset(coords) returns jQuery object" );
+ assert.equal( jQuery( "#non-existent" ).offset( coords ).selector, "#non-existent", "offset(coords) with empty jQuery set returns jQuery object" );
+ assert.equal( jQuery( "#absolute-1" ).offset( undefined ).selector, "#absolute-1", "offset(undefined) returns jQuery object (#5571)" );
} );
QUnit.test( "offsetParent", function( assert ) {