[OpenLayers-Commits] r11771 - in trunk/openlayers: lib/OpenLayers/Handler tests/Handler

commits-20090109 at openlayers.org commits-20090109 at openlayers.org
Wed Mar 30 04:25:44 EDT 2011


Author: erilem
Date: 2011-03-30 01:25:40 -0700 (Wed, 30 Mar 2011)
New Revision: 11771

Modified:
   trunk/openlayers/lib/OpenLayers/Handler/Click.js
   trunk/openlayers/tests/Handler/Click.html
Log:
click handler fires a "click" event when it should not, r=sbrunner (closes #3202)

Modified: trunk/openlayers/lib/OpenLayers/Handler/Click.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Handler/Click.js	2011-03-30 08:16:47 UTC (rev 11770)
+++ trunk/openlayers/lib/OpenLayers/Handler/Click.js	2011-03-30 08:25:40 UTC (rev 11771)
@@ -191,6 +191,7 @@
             evt.xy = this.last.xy;
             evt.lastTouches = this.last.touches;
             this.handleSingle(evt);
+            this.down = null;
         }
         return true;
     },

Modified: trunk/openlayers/tests/Handler/Click.html
===================================================================
--- trunk/openlayers/tests/Handler/Click.html	2011-03-30 08:16:47 UTC (rev 11770)
+++ trunk/openlayers/tests/Handler/Click.html	2011-03-30 08:25:40 UTC (rev 11771)
@@ -489,7 +489,7 @@
     }
 
     function test_touch_click(t) {
-        t.plan(4);
+        t.plan(5);
 
         // set up
 
@@ -511,6 +511,7 @@
 
         // test
 
+        // the common case: a touchstart followed by a touchend
         log = null;
         handler.touchstart({xy: px(1, 1), touches: ["foo"]});
         handler.touchend({touches: ["foo"]});
@@ -522,8 +523,19 @@
                 t.eq(log.y, 1, "evt.xy.y as expected");
                 t.ok(log.lastTouches, "evt.lastTouches as expected");
             }
-            // tear down
-            map.destroy();
+
+            // now emulate a touch where touchstart doesn't propagate
+            // to the click handler, i.e. the click handler gets a
+            // touchend only
+            log = null;
+            handler.touchend({touches: ["foo"]});
+
+            t.delay_call(1, function() {
+                t.ok(log == null, "click callback not called");
+
+                // tear down
+                map.destroy();
+            });
         });
     }
 



More information about the Commits mailing list