aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManolo Carrasco <manolo@apache.org>2010-10-25 11:17:04 +0000
committerManolo Carrasco <manolo@apache.org>2010-10-25 11:17:04 +0000
commit3e082d583fdb05f659dbdb35f8d4ccb4477ae4f3 (patch)
tree6a4dccac615f159631f9eeec32f9239e6aee617f
parent291e7670bddcf425f4e1c86d2feccddb7ce32b84 (diff)
downloadgwtquery-3e082d583fdb05f659dbdb35f8d4ccb4477ae4f3.tar.gz
gwtquery-3e082d583fdb05f659dbdb35f8d4ccb4477ae4f3.zip
fixing unbind with multiple events (fixes issue48)
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/Query.gwt.xml3
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/EventsListener.java2
-rw-r--r--gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryEventsTest.java27
3 files changed, 30 insertions, 2 deletions
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/Query.gwt.xml b/gwtquery-core/src/main/java/com/google/gwt/query/Query.gwt.xml
index 6a3cd06c..b202a109 100644
--- a/gwtquery-core/src/main/java/com/google/gwt/query/Query.gwt.xml
+++ b/gwtquery-core/src/main/java/com/google/gwt/query/Query.gwt.xml
@@ -84,7 +84,8 @@
<when-property-is name="user.agent" value="ie8"/>
</replace-with>
- <!-- IE8 needs the iframe with the app set to standard to use native selector -->
+ <!-- IE8 needs the iframe where the js of app is loaded set to standard in order
+ to use the queryAll native selector -->
<define-linker name="stddoctype" class="com.google.gwt.query.linker.IFrameWithDocTypeLinker"/>
<add-linker name="stddoctype"/>
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/EventsListener.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/EventsListener.java
index 93fb6881..01fe9498 100644
--- a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/EventsListener.java
+++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/EventsListener.java
@@ -66,7 +66,7 @@ public class EventsListener implements EventListener {
}
public boolean hasEventType(int etype) {
- return (type | etype) == type;
+ return (type & etype) == type;
}
}
// Gwt Events class has not this event defined
diff --git a/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryEventsTest.java b/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryEventsTest.java
index ff5ceb5c..eb794e26 100644
--- a/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryEventsTest.java
+++ b/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryEventsTest.java
@@ -16,6 +16,7 @@
package com.google.gwt.query.client;
import static com.google.gwt.query.client.GQuery.$;
+import static com.google.gwt.query.client.GQuery.document;
import static com.google.gwt.query.client.GQuery.lazy;
import com.google.gwt.dom.client.Element;
@@ -290,4 +291,30 @@ public class GQueryEventsTest extends GWTTestCase {
assertEquals("black", $("button").css("background-color"));
RootPanel.get().remove(b);
}
+
+
+ public void testUnbindMultipleEvents() {
+ String content = "<p>content</p>";
+ $(e).html(content);
+ $(document).bind(Event.ONMOUSEMOVE, null, new Function() {
+ public void f(Element e){
+ $("p").css("color", "red");
+ }
+ });
+ $(document).bind(Event.ONMOUSEUP, null, new Function(){
+ public void f(Element e){
+ $("p").css("color", "yellow");
+ }
+ });
+ $(document).trigger(Event.ONMOUSEMOVE);
+ assertEquals("red", $("p").css("color"));
+ $(document).trigger(Event.ONMOUSEUP);
+ assertEquals("yellow", $("p").css("color"));
+ $("p").css("color", "black");
+ $(document).unbind(Event.ONMOUSEUP|Event.ONMOUSEMOVE);
+ $(document).trigger(Event.ONMOUSEMOVE);
+ assertEquals("black", $("p").css("color"));
+ $(document).trigger(Event.ONMOUSEUP);
+ assertEquals("black", $("p").css("color"));
+ }
}