]> source.dussan.org Git - jquery.git/commitdiff
Merge branch 'bug_7931' of https://github.com/Xavi-/jquery into Xavi--bug_7931
authorJohn Resig <jeresig@gmail.com>
Tue, 12 Apr 2011 20:13:56 +0000 (16:13 -0400)
committerJohn Resig <jeresig@gmail.com>
Tue, 12 Apr 2011 20:13:56 +0000 (16:13 -0400)
Conflicts:
src/offset.js

1  2 
src/offset.js
test/unit/offset.js

diff --cc src/offset.js
index 95177434ccb1e134d1f6bd4d2ebf1b3f1bc58067,8696c205149ce2150823869d566d431cc200aeaa..31f2503a41b0a073c343a66566d41eb867325bca
@@@ -261,37 -260,36 +261,39 @@@ jQuery.fn.extend(
  jQuery.each( ["Left", "Top"], function( i, name ) {
        var method = "scroll" + name;
  
-       jQuery.fn[ method ] = function(val) {
-               var elem = this[0], win;
+       jQuery.fn[ method ] = function( val ) {
+               var elem, win;
  
-               if ( !elem ) {
-                       return null;
-               }
-               if ( val !== undefined ) {
-                       // Set the scroll offset
-                       return this.each(function() {
-                               win = getWindow( this );
 -              if( val === undefined ) {
++              if ( val === undefined ) {
+                       elem = this[ 0 ];
 -                      if( !elem ) {
 +
-                               if ( win ) {
-                                       win.scrollTo(
-                                               !i ? val : jQuery(win).scrollLeft(),
-                                               i ? val : jQuery(win).scrollTop()
-                                       );
++                      if ( !elem ) {
+                               return null;
+                       }
  
-                               } else {
-                                       this[ method ] = val;
-                               }
-                       });
-               } else {
                        win = getWindow( elem );
 +
                        // Return the scroll offset
                        return win ? ("pageXOffset" in win) ? win[ i ? "pageYOffset" : "pageXOffset" ] :
                                jQuery.support.boxModel && win.document.documentElement[ method ] ||
                                        win.document.body[ method ] :
                                elem[ method ];
                }
+               // Set the scroll offset
+               return this.each(function() {
+                       win = getWindow( this );
+                       if ( win ) {
+                               win.scrollTo(
+                                       !i ? val : jQuery( win ).scrollLeft(),
+                                        i ? val : jQuery( win ).scrollTop()
+                               );
++
+                       } else {
+                               this[ method ] = val;
+                       }
+               });
        };
  });
  
Simple merge