Skip to content

Commit ea507b3

Browse files
committedOct 14, 2010
Make sure that we don't attempt to handle scrolling when the node is disconnected from the document. Fixes #7190.
1 parent d490bcf commit ea507b3

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed
 

‎src/offset.js

+8-5
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,17 @@ if ( "getBoundingClientRect" in document.documentElement ) {
2323

2424
try {
2525
box = elem.getBoundingClientRect();
26+
} catch(e) {}
2627

27-
} catch(e) {
28-
return { top: 0, left: 0 };
28+
var doc = elem.ownerDocument,
29+
docElem = doc.documentElement;
30+
31+
// Make sure we're not dealing with a disconnected DOM node
32+
if ( !box || !jQuery.contains( docElem, elem ) ) {
33+
return box || { top: 0, left: 0 };
2934
}
3035

31-
var doc = elem.ownerDocument,
32-
body = doc.body,
33-
docElem = doc.documentElement,
36+
var body = doc.body,
3437
win = getWindow(doc),
3538
clientTop = docElem.clientTop || body.clientTop || 0,
3639
clientLeft = docElem.clientLeft || body.clientLeft || 0,

0 commit comments

Comments
 (0)