*/
public String curCSS(Element elem, String name, boolean force) {
name = fixPropertyName(name);
+ //value defined in the element style
+ String ret = elem.getStyle().getProperty(name);
+
if ("height".equalsIgnoreCase(name)) {
- return String.valueOf(getHeight(elem));
+ return force ? String.valueOf(getHeight(elem))+"px" : ret;
}
if ("width".equalsIgnoreCase(name)) {
- return String.valueOf(getWidth(elem));
+ return force ? String.valueOf(getWidth(elem))+"px" : ret;
}
if ("opacity".equalsIgnoreCase(name)) {
- return String.valueOf(getOpacity(elem));
+ return force ? String.valueOf(getOpacity(elem)) : ret;
}
- if (!force && elem.getStyle().getProperty(name) != null) {
- String ret = elem.getStyle().getProperty(name);
+ if (!force) {
return ret == null ? "" : ret;
} else {
return getComputedStyle(elem, hyphenize(name), name, null);
}
}
+
/**
* Fix style property names.
*/
assertEquals("0.6", g.css("opacity", false));
assertEquals("0.6", g.css("opacity", true));
g.css("opacity", "");
- assertEquals("1.0", g.css("opacity", false));
+ assertEquals("", g.css("opacity", false));
assertEquals("1.0", g.css("opacity", true));
g.css("opacity", "0.4");
assertEquals("0.4", g.css("opacity", false));
assertEquals(100, (int)GQUtils.cur(g.get(0), "height", false));
assertEquals(100, (int)GQUtils.cur(g.get(0), "width", true));
assertEquals(100, (int)GQUtils.cur(g.get(0), "height", true));
- assertEquals("100", g.css("width"));
- assertEquals("100", g.css("height"));
+ assertEquals("100px", g.css("width"));
+ assertEquals("100px", g.css("height"));
assertEquals("100px", g.get(0).getStyle().getProperty("width"));
assertEquals("100px", g.get(0).getStyle().getProperty("height"));
}