From 844acfea149e70f3a03f43bc0a2f2bdc34e762ba Mon Sep 17 00:00:00 2001 From: Manolo Carrasco Date: Fri, 30 Sep 2011 08:02:38 +0000 Subject: [PATCH] IE was raising exception when manipulating css attr in xml nodes. Do not print stacktraces in prod --- .../gwt/query/client/impl/DocumentStyleImpl.java | 11 +++-------- .../gwt/query/client/impl/DocumentStyleImplIE.java | 8 ++++---- .../query/client/impl/SelectorEngineCssToXPath.java | 13 ++++++++----- 3 files changed, 15 insertions(+), 17 deletions(-) diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/DocumentStyleImpl.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/DocumentStyleImpl.java index 7cd8b90f..39ba47e6 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/DocumentStyleImpl.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/DocumentStyleImpl.java @@ -93,15 +93,10 @@ public class DocumentStyleImpl { if ("opacity".equalsIgnoreCase(name)) { return force ? String.valueOf(getOpacity(elem)) : ret; } - if (!force) { - return ret == null ? "" : ret; - } else { - try { - return getComputedStyle(elem, JsUtils.hyphenize(name), name, null); - } catch (Exception e) { - return ret; - } + if (force) { + ret = getComputedStyle(elem, JsUtils.hyphenize(name), name, null); } + return ret == null ? "" : ret; } /** diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/DocumentStyleImplIE.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/DocumentStyleImplIE.java index 318a81a9..37c05420 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/DocumentStyleImplIE.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/DocumentStyleImplIE.java @@ -62,9 +62,9 @@ public class DocumentStyleImplIE extends DocumentStyleImpl { /** * Remove a style property from an element. */ - public native void removeStyleProperty(Element elem, String prop) /*-{ - if (elem && elem.style && elem.removeAttribute) - elem.style.removeAttribute(prop); + public native void removeStyleProperty(Element e, String prop) /*-{ + if (e && e.style && 'removeAttribute' in e) + e.style.removeAttribute(prop); }-*/; @@ -85,7 +85,7 @@ public class DocumentStyleImplIE extends DocumentStyleImpl { protected native String getComputedStyle(Element elem, String hyphenName, String camelName, String pseudo) /*-{ // code lifted from jQuery - if (!elem.style || !elem.currentStyle || !elem.runtimeStyle) return null; + if (!elem.style || !'currentStyle' in elem || !'runtimeStyle' in elem) return null; var style = elem.style; var ret = elem.currentStyle[hyphenName] || elem.currentStyle[camelName]; if ( !/^\d+(px)?$/i.test( ret ) && /^\d/.test( ret ) ) { diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngineCssToXPath.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngineCssToXPath.java index 7b33ede6..85c85d0f 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngineCssToXPath.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngineCssToXPath.java @@ -17,6 +17,7 @@ package com.google.gwt.query.client.impl; import java.util.ArrayList; +import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.JsArray; import com.google.gwt.dom.client.Element; import com.google.gwt.dom.client.Node; @@ -224,12 +225,14 @@ public class SelectorEngineCssToXPath extends SelectorEngineImpl { SelectorEngine.xpathEvaluate(xsel, ctx, elm); return JsUtils.unique(elm.> cast()).cast(); } catch (Exception e) { - if (!SelectorEngine.hasXpathEvaluate()) { - throw new RuntimeException("This Browser does not support Xpath selectors.", e); - } - System.err.println("ERROR: xpathEvaluate invalid xpath expression:" + if (GWT.isScript()) { + if (!SelectorEngine.hasXpathEvaluate()) { + throw new RuntimeException("This Browser does not support Xpath selectors.", e); + } + System.err.println("ERROR: xpathEvaluate invalid xpath expression:" + xsel + " css-selector:" + sel + "\n"); - e.printStackTrace(); + e.printStackTrace(); + } return elm; } } -- 2.39.5