From: Manolo Carrasco Date: Tue, 25 Jan 2011 06:46:02 +0000 (+0000) Subject: Fix detection of the window, before this fix f(Element e) did not work with when... X-Git-Tag: release-1.3.2~553 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=4be89bfb71069d8196871a00652bacb5282f871d;p=gwtquery.git Fix detection of the window, before this fix f(Element e) did not work with when adding scroll binding to the window $(window).scroll(Function ) --- 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 1576f622..0b64490a 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 @@ -442,7 +442,7 @@ public class GQuery implements Lazy { windowData = JavaScriptObject.createObject().cast(); dataCache = JavaScriptObject.createObject().cast(); } - item = item == window ? windowData : item; + item = item == window || item.getNodeName() == null? windowData : item; if (item == null) { return value; } @@ -2098,7 +2098,7 @@ public class GQuery implements Lazy { */ public int scrollLeft() { Element e = get(0); - if (e == window) { + if (e == window || e.getNodeName() == null) { return Window.getScrollLeft(); } else if (e == (Node) document) { return document.getScrollLeft(); @@ -2114,7 +2114,7 @@ public class GQuery implements Lazy { */ public GQuery scrollLeft(int left) { for (Element e : elements()) { - if (e == window || e == (Node) document) { + if (e == window || e.getNodeName() == null || e == (Node) document) { Window.scrollTo(left, $(e).scrollTop()); } else { e.setPropertyInt("scrollLeft", left); @@ -2129,7 +2129,7 @@ public class GQuery implements Lazy { */ public int scrollTop() { Element e = get(0); - if (e == window) { + if (e == window || e.getNodeName() == null) { return Window.getScrollTop(); } else if (e == (Node) document) { return document.getScrollTop(); @@ -2145,7 +2145,7 @@ public class GQuery implements Lazy { */ public GQuery scrollTop(int top) { for (Element e : elements()) { - if (e == window || e == (Node) document) { + if (e == window || e.getNodeName() == null || e == (Node) document) { Window.scrollTo($(e).scrollLeft(), top); } else { e.setPropertyInt("scrollTop", top); @@ -2828,7 +2828,7 @@ public class GQuery implements Lazy { windowData = JavaScriptObject.createObject().cast(); dataCache = JavaScriptObject.createObject().cast(); } - item = item == window ? windowData : item; + item = item == window || item.getNodeName() == null? windowData : item; int id = item.hashCode(); if (name != null) { if (dataCache.exists(id)) {