aboutsummaryrefslogtreecommitdiffstats
path: root/src/offset.js
diff options
context:
space:
mode:
authorXavi <xavi.rmz@gmail.com>2011-01-09 19:11:05 -0500
committerXavi <xavi.rmz@gmail.com>2011-01-09 19:11:05 -0500
commitd03d2e9f26f85366ad2e91b9e2c76a249d7bf7be (patch)
tree76e9a6c1cfc11c1b3176e42a85437c4a675a854f /src/offset.js
parentfcf623786aeae20485e5253bd2b66c8758053646 (diff)
downloadjquery-d03d2e9f26f85366ad2e91b9e2c76a249d7bf7be.tar.gz
jquery-d03d2e9f26f85366ad2e91b9e2c76a249d7bf7be.zip
Bug 7931; Fixed bug that caused scrollTop and scrollLeft setters to return null when called on an empty jquery object
Diffstat (limited to 'src/offset.js')
-rw-r--r--src/offset.js28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/offset.js b/src/offset.js
index 2040c9d83..d53a8813b 100644
--- a/src/offset.js
+++ b/src/offset.js
@@ -261,13 +261,9 @@ jQuery.each( ["Left", "Top"], function( i, name ) {
var method = "scroll" + name;
jQuery.fn[ method ] = function(val) {
- var elem = this[0], win;
+ var elem, win;
- if ( !elem ) {
- return null;
- }
-
- if ( val !== undefined ) {
+ if ( val != undefined ) {
// Set the scroll offset
return this.each(function() {
win = getWindow( this );
@@ -282,15 +278,19 @@ jQuery.each( ["Left", "Top"], function( i, name ) {
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 ];
}
+
+ elem = this[0];
+ if( !elem ) {
+ return null
+ }
+
+ 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 ];
};
});