]> source.dussan.org Git - jquery.git/commitdiff
Revert "Offset: account for scroll when calculating position"
authorOleg Gaidarenko <markelog@gmail.com>
Mon, 8 Feb 2016 20:39:43 +0000 (23:39 +0300)
committerOleg Gaidarenko <markelog@gmail.com>
Mon, 8 Feb 2016 21:10:02 +0000 (00:10 +0300)
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

src/offset.js
test/unit/offset.js

index 43fb0155a9096d41b814c88b73608fed024f9748..3e5bb97b537ed8c8edea0efd81b34ab3291ac1a8 100644 (file)
@@ -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
index b8e0c697758350ff328aedde5dac43b445d93fc9..15d3895c3be500d59e67f00748bc923d3f8aa9d9 100644 (file)
@@ -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 ) {