Fix issue on IE occuring when nodes are removed from DOM.

This commit is contained in:
Jürg Lehni 2013-06-13 09:08:11 -07:00
parent 7f6ac3d8af
commit d87937dc03

View file

@ -140,11 +140,19 @@ var DomElement = new function() {
},
getBounds: function(el, viewport) {
var rect = el.getBoundingClientRect(),
doc = el.ownerDocument,
var doc = el.ownerDocument,
body = doc.body,
html = doc.documentElement,
x = rect.left - (html.clientLeft || body.clientLeft || 0),
rect;
try {
// On IE, for nodes that are not inside the DOM, this throws an
// exception. Emulate the behavior of all other browsers, which
// return a rectangle of 0 dimensions.
rect = el.getBoundingClientRect();
} catch(e) {
rect = { left: 0, top: 0, width: 0, height: 0 };
}
var x = rect.left - (html.clientLeft || body.clientLeft || 0),
y = rect.top - (html.clientTop || body.clientTop || 0);
if (!viewport) {
var view = doc.defaultView;