OpenLayers OpenLayers

Changeset 6414

Show
Ignore:
Timestamp:
02/29/08 02:30:34 (10 months ago)
Author:
tschaub
Message:

The click and hover handlers need to take care that the event they are handling doesn't get modified before the delayed listeners get called. Appears to only be a problem in IE. Thanks for the catch madair. r=crschmidt (closes #1393)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/openlayers/lib/OpenLayers/Handler/Click.js

    r6131 r6414  
    160160            } else { 
    161161                // set the timer, send evt only if single is true 
    162                 var clickEvent = this.single ? evt : null; 
     162                //use a clone of the event object because it will no longer  
     163                //be a valid event object in IE in the timer callback 
     164                var clickEvent = this.single ? 
     165                    OpenLayers.Util.extend({}, evt) : null; 
    163166                this.timerId = window.setTimeout( 
    164167                    OpenLayers.Function.bind(this.delayedCall, this, clickEvent), 
  • trunk/openlayers/lib/OpenLayers/Handler/Hover.js

    r6131 r6414  
    8787            this.callback('move', [evt]); 
    8888            this.px = evt.xy; 
     89            // clone the evt so original properties can be accessed even 
     90            // if the browser deletes them during the delay 
     91            evt = OpenLayers.Util.extend({}, evt); 
    8992            this.timerId = window.setTimeout( 
    9093                OpenLayers.Function.bind(this.delayedCall, this, evt), 
  • trunk/openlayers/tests/Handler/test_Click.html

    r6131 r6414  
    130130            } 
    131131        } 
    132         var testEvt = Math.random()
    133         handler.callbacks = { 
    134             "click": function(evt) { 
    135                 t.eq(evt, testEvt
     132        var testEvt = {id: Math.random()}
     133        handler.callbacks = { 
     134            "click": function(evt) { 
     135                t.eq(evt.id, testEvt.id
    136136                     "(click w/ single true) click callback called with correct evt"); 
    137137            }, 
     
    204204        handler.callbacks = { 
    205205            "click": function(evt) { 
    206                 t.ok(evt == clickEvt, "(pixelTolerance met) click called"); 
     206                t.ok(evt.xy == clickEvt.xy, "(pixelTolerance met) click called"); 
    207207            } 
    208208        }; 
  • trunk/openlayers/tests/Handler/test_Hover.html

    r6131 r6414  
    7979 
    8080        // test pause and move callbacks - four tests here (2 from setTimeout above) 
    81         testEvt = Math.random()
     81        testEvt = {id: Math.random()}
    8282        handler.callbacks = { 
    8383            "pause": function(evt) { 
    84                 t.eq(evt, testEvt
     84                t.eq(evt.id, testEvt.id
    8585                     "pause callback called with correct evt"); 
    86             }, 
    87             "move": function(evt) { 
    88                 t.eq(evt, testEvt
    89                     "move callback called with correct evt"); 
    90            
     86            }, 
     87            "move": function(evt) { 
     88               t.eq(evt.id, testEvt.id
     89                   "move callback called with correct evt"); 
     90           
    9191        }; 
    9292        map.events.triggerEvent("mousemove", testEvt); 
     
    117117        handler.callbacks =  { 
    118118            "pause": function(evt) { 
    119                 t.ok(evt == testEvt, "(pixelTolerance unmet) pause callback called"); 
     119                t.ok(evt.xy == testEvt.xy, "(pixelTolerance unmet) pause callback called"); 
    120120            }, 
    121121            "move": function(evt) {