diff options
author | John Resig <jeresig@gmail.com> | 2010-10-14 14:52:31 -0400 |
---|---|---|
committer | John Resig <jeresig@gmail.com> | 2010-10-14 14:52:31 -0400 |
commit | ea507b3e998126ae1f94f4fd1618994d645c9cc8 (patch) | |
tree | f5433dd45b16c7508f06b94843cf17483852d76f /src/offset.js | |
parent | d490bcfa7ca78a330e55b9267cc492a49c0f70bb (diff) | |
download | jquery-ea507b3e998126ae1f94f4fd1618994d645c9cc8.tar.gz jquery-ea507b3e998126ae1f94f4fd1618994d645c9cc8.zip |
Make sure that we don't attempt to handle scrolling when the node is disconnected from the document. Fixes #7190.
Diffstat (limited to 'src/offset.js')
-rw-r--r-- | src/offset.js | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/offset.js b/src/offset.js index bbb19c2e3..b94faf37b 100644 --- a/src/offset.js +++ b/src/offset.js @@ -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, |