]> source.dussan.org Git - jquery.git/commitdiff
Make sure that we don't attempt to handle scrolling when the node is disconnected...
authorJohn Resig <jeresig@gmail.com>
Thu, 14 Oct 2010 18:52:31 +0000 (14:52 -0400)
committerJohn Resig <jeresig@gmail.com>
Thu, 14 Oct 2010 18:52:31 +0000 (14:52 -0400)
src/offset.js

index bbb19c2e3126f317cea98b43acd5f0b347e4c8ca..b94faf37b200a612ac16626ed0cb3b53c7531fd0 100644 (file)
@@ -23,14 +23,17 @@ if ( "getBoundingClientRect" in document.documentElement ) {
 
                try {
                        box = elem.getBoundingClientRect();
+               } catch(e) {}
 
-               } catch(e) {
-                       return { top: 0, left: 0 };
+               var doc = elem.ownerDocument,
+                       docElem = doc.documentElement;
+
+               // Make sure we're not dealing with a disconnected DOM node
+               if ( !box || !jQuery.contains( docElem, elem ) ) {
+                       return box || { top: 0, left: 0 };
                }
 
-               var doc = elem.ownerDocument,
-                       body = doc.body,
-                       docElem = doc.documentElement,
+               var body = doc.body,
                        win = getWindow(doc),
                        clientTop  = docElem.clientTop  || body.clientTop  || 0,
                        clientLeft = docElem.clientLeft || body.clientLeft || 0,