Moved from the old JSMin to using YUIMin for compressing the jQuery source. Additiona...
[jquery.git] / src / offset.js
index 479f106..cc1b874 100644 (file)
@@ -2,9 +2,10 @@ if ( document.documentElement["getBoundingClientRect"] )
        jQuery.fn.offset = function() {
                if ( !this[0] ) return { top: 0, left: 0 };
                if ( this[0] === this[0].ownerDocument.body ) return jQuery.offset.bodyOffset( this[0] );
-               var box  = this[0].getBoundingClientRect(), doc = this[0].ownerDocument, docElem = doc.documentElement,
-                       top  = box.top  + (self.pageYOffset || jQuery.boxModel && docElem.scrollTop  || doc.body.scrollTop ) - docElem.clientTop,
-                       left = box.left + (self.pageXOffset || jQuery.boxModel && docElem.scrollLeft || doc.body.scrollLeft) - docElem.clientLeft;
+               var box  = this[0].getBoundingClientRect(), doc = this[0].ownerDocument, body = doc.body, docElem = doc.documentElement,
+                       clientTop = docElem.clientTop || body.clientTop || 0, clientLeft = docElem.clientLeft || body.clientLeft || 0,
+                       top  = box.top  + (self.pageYOffset || jQuery.boxModel && docElem.scrollTop  || body.scrollTop ) - clientTop,
+                       left = box.left + (self.pageXOffset || jQuery.boxModel && docElem.scrollLeft || body.scrollLeft) - clientLeft;
                return { top: top, left: left };
        };
 else 
@@ -49,10 +50,10 @@ else
 jQuery.offset = {
        initialize: function() {
                if ( this.initialized ) return;
-               var body = document.body, container = document.createElement('div'), innerDiv, checkDiv, table, rules, prop, bodyMarginTop = body.style.marginTop,
+               var body = document.body, container = document.createElement('div'), innerDiv, checkDiv, table, td, rules, prop, bodyMarginTop = body.style.marginTop,
                        html = '<div style="position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;"><div></div></div><table style="position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;"cellpadding="0"cellspacing="0"><tr><td></td></tr></table>';
 
-               rules = { position: 'absolute', top: 0, left: 0, margin: 0, border: 0, width: '1px', height: '1px', visibility: 'hidden' }
+               rules = { position: 'absolute', top: 0, left: 0, margin: 0, border: 0, width: '1px', height: '1px', visibility: 'hidden' };
                for ( prop in rules ) container.style[prop] = rules[prop];
 
                container.innerHTML = html;
@@ -130,9 +131,9 @@ jQuery.each( ['Left', 'Top'], function(i, name) {
        var method = 'scroll' + name;
        
        jQuery.fn[ method ] = function(val) {
-               if (!this[0]) return;
+               if (!this[0]) return null;
 
-               return val != undefined ?
+               return val !== undefined ?
 
                        // Set the scroll offset
                        this.each(function() {