Fixed a bug in DOMImplIE6.getAbsoluteTop/Left() where the method throws a JS exception if the element is not attached to the DOM.
Patch by: jlabanca
Review by: ecc (TBR)
Issue: 3270
git-svn-id: https://google-web-toolkit.googlecode.com/svn/releases/1.6@4420 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/user/src/com/google/gwt/dom/client/DOMImplIE6.java b/user/src/com/google/gwt/dom/client/DOMImplIE6.java
index 36fad77..ba1dfaa 100644
--- a/user/src/com/google/gwt/dom/client/DOMImplIE6.java
+++ b/user/src/com/google/gwt/dom/client/DOMImplIE6.java
@@ -41,16 +41,28 @@
@Override
public native int getAbsoluteLeft(Element elem) /*-{
- return (elem.getBoundingClientRect().left /
- this.@com.google.gwt.dom.client.DOMImplIE6::getZoomMultiple()()) +
- @com.google.gwt.user.client.impl.DocumentRootImpl::documentRoot.scrollLeft;
+ // getBoundingClientRect() throws a JS exception if the elem is not attached
+ // to the document, so we wrap it in a try/catch block
+ try {
+ return (elem.getBoundingClientRect().left /
+ this.@com.google.gwt.dom.client.DOMImplIE6::getZoomMultiple()()) +
+ @com.google.gwt.user.client.impl.DocumentRootImpl::documentRoot.scrollLeft;
+ } catch (e) {
+ return 0;
+ }
}-*/;
@Override
public native int getAbsoluteTop(Element elem) /*-{
- return (elem.getBoundingClientRect().top /
- this.@com.google.gwt.dom.client.DOMImplIE6::getZoomMultiple()()) +
- @com.google.gwt.user.client.impl.DocumentRootImpl::documentRoot.scrollTop;
+ // getBoundingClientRect() throws a JS exception if the elem is not attached
+ // to the document, so we wrap it in a try/catch block
+ try {
+ return (elem.getBoundingClientRect().top /
+ this.@com.google.gwt.dom.client.DOMImplIE6::getZoomMultiple()()) +
+ @com.google.gwt.user.client.impl.DocumentRootImpl::documentRoot.scrollTop;
+ } catch (e) {
+ return 0;
+ }
}-*/;
public native int getBodyOffsetLeft() /*-{