From f4a3eafc8661f3e3f199f138f8448d9c7dda107c Mon Sep 17 00:00:00 2001 From: Manolo Carrasco Date: Mon, 24 Oct 2011 14:34:11 +0000 Subject: [PATCH] Adds px to numeric css attributes, like jquery does --- .../google/gwt/query/client/impl/DocumentStyleImpl.java | 7 +++++++ 1 file changed, 7 insertions(+) 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); } } -- 2.39.5