We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent d490bcf commit ea507b3Copy full SHA for ea507b3
src/offset.js
@@ -23,14 +23,17 @@ if ( "getBoundingClientRect" in document.documentElement ) {
23
24
try {
25
box = elem.getBoundingClientRect();
26
+ } catch(e) {}
27
- } catch(e) {
28
- return { top: 0, left: 0 };
+ 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 };
34
}
35
- var doc = elem.ownerDocument,
- body = doc.body,
- docElem = doc.documentElement,
36
+ var body = doc.body,
37
win = getWindow(doc),
38
clientTop = docElem.clientTop || body.clientTop || 0,
39
clientLeft = docElem.clientLeft || body.clientLeft || 0,
0 commit comments