offset: make sure there is a parent node to work on while calculating scroll offsets...
[jquery.git] / src / offset.js
index 11a187e..8ee5680 100644 (file)
@@ -55,7 +55,7 @@ jQuery.fn.offset = function() {
                        }
                
                        // Get parent scroll offsets
-                       while ( parent.tagName && !/^body|html$/i.test(parent.tagName) ) {
+                       while ( parent && parent.tagName && !/^body|html$/i.test(parent.tagName) ) {
                                // Remove parent scroll UNLESS that parent is inline or a table to work around Opera inline/table scrollLeft/Top bug
                                if ( !/^inline|table.*$/i.test(jQuery.css(parent, "display")) )
                                        // Subtract parent scroll offsets
@@ -86,7 +86,7 @@ jQuery.fn.offset = function() {
        }
 
        function border(elem) {
-               add( jQuery.css(elem, "borderLeftWidth"), jQuery.css(elem, "borderTopWidth") );
+               add( jQuery.curCSS(elem, "borderLeftWidth", true), jQuery.curCSS(elem, "borderTopWidth", true) );
        }
 
        function add(l, t) {