From: Manolo Carrasco Date: Mon, 24 Oct 2011 14:34:11 +0000 (+0000) Subject: Adds px to numeric css attributes, like jquery does X-Git-Tag: release-1.3.2~153 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=f4a3eafc8661f3e3f199f138f8448d9c7dda107c;p=gwtquery.git Adds px to numeric css attributes, like jquery does --- 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 cd716fe9..da318b55 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 @@ -19,6 +19,7 @@ import com.google.gwt.dom.client.Document; import com.google.gwt.dom.client.Element; import com.google.gwt.query.client.GQuery; import com.google.gwt.query.client.js.JsNamedArray; +import com.google.gwt.query.client.js.JsRegexp; import com.google.gwt.query.client.js.JsUtils; import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.Window; @@ -27,6 +28,9 @@ import com.google.gwt.user.client.Window; * A helper class to get computed CSS styles for elements. */ public class DocumentStyleImpl { + + private static final JsRegexp cssNumber = new JsRegexp("^(fillOpacity|fontWeight|lineHeight|opacity|orphans|widows|zIndex|zoom)$", "i"); + /** * Returns the numeric value of a css property. * @@ -160,6 +164,9 @@ public class DocumentStyleImpl { if (val == null || val.trim().length() == 0) { removeStyleProperty(e, prop); } else { + if (val.matches("-?[\\d\\.]+") && !cssNumber.test(val)) { + val += "px"; + } e.getStyle().setProperty(prop, val); } }