Clean up expando removal code - only try to delete the expando from an element if...
[jquery.git] / src / offset.js
index 7dd7134..f80574e 100644 (file)
@@ -2,16 +2,16 @@ if ( "getBoundingClientRect" in document.documentElement ) {
        jQuery.fn.offset = function( options ) {
                var elem = this[0];
 
-               if ( !elem || !elem.ownerDocument ) {
-                       return null;
-               }
-
                if ( options ) { 
                        return this.each(function( i ) {
-                               jQuery.offset.setOffset( this, i, options );
+                               jQuery.offset.setOffset( this, options, i );
                        });
                }
 
+               if ( !elem || !elem.ownerDocument ) {
+                       return null;
+               }
+
                if ( elem === elem.ownerDocument.body ) {
                        return jQuery.offset.bodyOffset( elem );
                }
@@ -28,16 +28,16 @@ if ( "getBoundingClientRect" in document.documentElement ) {
        jQuery.fn.offset = function( options ) {
                var elem = this[0];
 
-               if ( !elem || !elem.ownerDocument ) {
-                       return null;
-               }
-
                if ( options ) { 
                        return this.each(function( i ) {
-                               jQuery.offset.setOffset( this, i, options );
+                               jQuery.offset.setOffset( this, options, i );
                        });
                }
 
+               if ( !elem || !elem.ownerDocument ) {
+                       return null;
+               }
+
                if ( elem === elem.ownerDocument.body ) {
                        return jQuery.offset.bodyOffset( elem );
                }
@@ -137,7 +137,7 @@ jQuery.offset = {
                return { top: top, left: left };
        },
        
-       setOffset: function( elem, i, options ) {
+       setOffset: function( elem, options, i ) {
                // set position first, in-case top/left are set even on static elem
                if ( /static/.test( jQuery.curCSS( elem, "position" ) ) ) {
                        elem.style.position = "relative";