]> source.dussan.org Git - gwtquery.git/commitdiff
Fix detection of the window, before this fix f(Element e) did not work with when...
authorManolo Carrasco <manolo@apache.org>
Tue, 25 Jan 2011 06:46:02 +0000 (06:46 +0000)
committerManolo Carrasco <manolo@apache.org>
Tue, 25 Jan 2011 06:46:02 +0000 (06:46 +0000)
gwtquery-core/src/main/java/com/google/gwt/query/client/GQuery.java

index 1576f622a1d24c84442c3d119704f32ce99d80da..0b64490a21938a8a78afab1fd39bdcdef661e119 100644 (file)
@@ -442,7 +442,7 @@ public class GQuery implements Lazy<GQuery, LazyGQuery> {
       windowData = JavaScriptObject.createObject().cast();\r
       dataCache = JavaScriptObject.createObject().cast();\r
     }\r
-    item = item == window ? windowData : item;\r
+    item = item == window || item.getNodeName() == null? windowData : item;\r
     if (item == null) {\r
       return value;\r
     }\r
@@ -2098,7 +2098,7 @@ public class GQuery implements Lazy<GQuery, LazyGQuery> {
    */\r
   public int scrollLeft() {\r
     Element e = get(0);\r
-    if (e == window) {\r
+    if (e == window || e.getNodeName() == null) {\r
       return Window.getScrollLeft();\r
     } else if (e == (Node) document) {\r
       return document.getScrollLeft();\r
@@ -2114,7 +2114,7 @@ public class GQuery implements Lazy<GQuery, LazyGQuery> {
    */\r
   public GQuery scrollLeft(int left) {\r
     for (Element e : elements()) {\r
-      if (e == window || e == (Node) document) {\r
+      if (e == window || e.getNodeName() == null || e == (Node) document) {\r
         Window.scrollTo(left, $(e).scrollTop());\r
       } else {\r
         e.setPropertyInt("scrollLeft", left);\r
@@ -2129,7 +2129,7 @@ public class GQuery implements Lazy<GQuery, LazyGQuery> {
    */\r
   public int scrollTop() {\r
     Element e = get(0);\r
-    if (e == window) {\r
+    if (e == window || e.getNodeName() == null) {\r
       return Window.getScrollTop();\r
     } else if (e == (Node) document) {\r
       return document.getScrollTop();\r
@@ -2145,7 +2145,7 @@ public class GQuery implements Lazy<GQuery, LazyGQuery> {
    */\r
   public GQuery scrollTop(int top) {\r
     for (Element e : elements()) {\r
-      if (e == window || e == (Node) document) {\r
+      if (e == window || e.getNodeName() == null || e == (Node) document) {\r
         Window.scrollTo($(e).scrollLeft(), top);\r
       } else {\r
         e.setPropertyInt("scrollTop", top);\r
@@ -2828,7 +2828,7 @@ public class GQuery implements Lazy<GQuery, LazyGQuery> {
       windowData = JavaScriptObject.createObject().cast();\r
       dataCache = JavaScriptObject.createObject().cast();\r
     }\r
-    item = item == window ? windowData : item;\r
+    item = item == window || item.getNodeName() == null? windowData : item;\r
     int id = item.hashCode();\r
     if (name != null) {\r
       if (dataCache.exists(id)) {\r