diff options
author | Manolo Carrasco <manolo@apache.org> | 2012-05-15 08:47:00 +0000 |
---|---|---|
committer | Manolo Carrasco <manolo@apache.org> | 2012-05-15 08:47:00 +0000 |
commit | 74c82ee9e8893ca18a0b125d51554c29763a7542 (patch) | |
tree | 404202f7f49e0e8a8b32239134474e4ee17e9db8 /gwtquery-core | |
parent | 6339cffd5a672bbfd544831962a7cf9575eb080c (diff) | |
download | gwtquery-74c82ee9e8893ca18a0b125d51554c29763a7542.tar.gz gwtquery-74c82ee9e8893ca18a0b125d51554c29763a7542.zip |
Fix NPE when calling styleImpl before it was initialized. Fix tests
Diffstat (limited to 'gwtquery-core')
-rw-r--r-- | gwtquery-core/src/main/java/com/google/gwt/query/client/GQuery.java | 11 | ||||
-rw-r--r-- | gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryCoreTestGwt.java | 17 |
2 files changed, 18 insertions, 10 deletions
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/GQuery.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/GQuery.java index 0bfa6baf..0570ba13 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/GQuery.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/GQuery.java @@ -1414,7 +1414,7 @@ public class GQuery implements Lazy<GQuery, LazyGQuery> { JsNodeArray result = JsNodeArray.create();
for (Element e : elements) {
if (JsUtils.isWindow(e) || "iframe".equalsIgnoreCase(e.getTagName())) {
- result.addNode(styleImpl.getContentDocument(e));
+ result.addNode(getStyleImpl().getContentDocument(e));
} else {
NodeList<Node> children = e.getChildNodes();
for (int i = 0, l = children.getLength(); i < l; i++) {
@@ -2012,7 +2012,7 @@ public class GQuery implements Lazy<GQuery, LazyGQuery> { public GQuery empty() {
for (Element e : elements) {
if (e.getNodeType() == Element.DOCUMENT_NODE) {
- styleImpl.emptyDocument(e.<Document> cast());
+ getStyleImpl().emptyDocument(e.<Document> cast());
} else {
Node c = e.getFirstChild();
while (c != null) {
@@ -2341,9 +2341,8 @@ public class GQuery implements Lazy<GQuery, LazyGQuery> { }
}
- // set the display value in a separate for loop to avoid constant reflow
- // Broswer reflow is triggered each time we gonna set and after get (in styleImpl.curCSS(e, "display", false) method)
- // the diplay property. Reflows is very bad in performance point of view
+ // Set the display value in a separate for loop to avoid constant reflow
+ // Reflows is very bad in performance point of view
for (Element e : elements){
e.getStyle().setDisplay(Display.NONE);
}
@@ -3756,7 +3755,7 @@ public class GQuery implements Lazy<GQuery, LazyGQuery> { elements = new Element[l];
for (int i = 0; i < l; i++) {
elements[i] = list.getItem(i);
- nodeList.<JsObjectArray>cast().add(list.getItem(i));
+ nodeList.<JsObjectArray<Element>>cast().add(list.getItem(i));
}
}
return this;
diff --git a/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryCoreTestGwt.java b/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryCoreTestGwt.java index 20eed559..a2ec3a62 100644 --- a/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryCoreTestGwt.java +++ b/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryCoreTestGwt.java @@ -1039,8 +1039,19 @@ public class GQueryCoreTestGwt extends GWTTestCase { assertEquals("mail", $("#cb", e).get(0).getAttribute("value")); $("#cb", e).removeAttr("value"); - assertEquals("", InputElement.as($("#cb", e).get(0)).getValue()); - assertEquals("", $("#cb", e).get(0).getAttribute("value")); + + // Now HtmlUnit returns a null, but it used to return empty + String val = InputElement.as($("#cb", e).get(0)).getValue(); + if ("null".equalsIgnoreCase(String.valueOf(val))) { + val = ""; + } + assertEquals("", val); + + val = $("#cb", e).get(0).getAttribute("value"); + if ("null".equalsIgnoreCase(String.valueOf(val))) { + val = ""; + } + assertEquals("", val); try{ $("#cb", e).attr("type", "hidden"); @@ -1052,8 +1063,6 @@ public class GQueryCoreTestGwt extends GWTTestCase { assertEquals("radio", InputElement.as(gq.get(0)).getType()); assertEquals("blop", InputElement.as(gq.get(0)).getValue()); - - gq.attr(Properties.create("{class:'test2', disabled:true}")); InputElement ie = InputElement.as(gq.get(0)); |