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;
}
/**
/**
* 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);
}-*/;
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 ) ) {
\r
import java.util.ArrayList;\r
\r
+import com.google.gwt.core.client.GWT;\r
import com.google.gwt.core.client.JsArray;\r
import com.google.gwt.dom.client.Element;\r
import com.google.gwt.dom.client.Node;\r
SelectorEngine.xpathEvaluate(xsel, ctx, elm);\r
return JsUtils.unique(elm.<JsArray<Element>> cast()).cast(); \r
} catch (Exception e) {\r
- if (!SelectorEngine.hasXpathEvaluate()) {\r
- throw new RuntimeException("This Browser does not support Xpath selectors.", e);\r
- }\r
- System.err.println("ERROR: xpathEvaluate invalid xpath expression:"\r
+ if (GWT.isScript()) {\r
+ if (!SelectorEngine.hasXpathEvaluate()) {\r
+ throw new RuntimeException("This Browser does not support Xpath selectors.", e);\r
+ }\r
+ System.err.println("ERROR: xpathEvaluate invalid xpath expression:"\r
+ xsel + " css-selector:" + sel + "\n");\r
- e.printStackTrace();\r
+ e.printStackTrace();\r
+ }\r
return elm;\r
}\r
}\r