Changeset 543 for branches


Ignore:
Timestamp:
08/05/06 11:50:48 (13 years ago)
Author:
mokhet
Message:

fix "event remove" issue where a wrong listener could be removed. ticket #658

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/mokhet/htmlarea.js

    r540 r543  
    65576557   * @param {string | array}       type     Event type to remove or indexed array of event types to remove 
    65586558   * @param {function}             handler  Event handler 
     6559   * @param {object}               scope    Execution scope (optional) default to the element reference 
    65596560   * @return {boolean} true if the removing is successfull 
    65606561   * @public 
    65616562   */ 
    6562   remove : function(element, type, handler) 
     6563  remove : function(element, type, handler, scope) 
    65636564  { 
    65646565    var returnValue = true; /* return value */ 
     
    65766577    if ( !Element ) { return false; } 
    65776578 
     6579    // determine application scope 
     6580    scope = scope ? scope : Element; 
     6581 
    65786582    var listener = null, 
    6579         listenerIndex = HTMLArea.Events._getListenerIndex(Element, type, handler); 
     6583        listenerIndex = HTMLArea.Events._getListenerIndex(Element, type, handler, scope); 
    65806584    if ( listenerIndex >= 0 ) 
    65816585    { 
     
    66366640   * @param {string}      type     Event type to search 
    66376641   * @param {function}    handler  Event handler to find 
     6642   * @param {object}      scope    Execution scope to match (optional) default to the element reference 
    66386643   * @return {integer} Index in the global listeners array 
    66396644   * @private 
    66406645  */ 
    6641   _getListenerIndex : function(Element, type, handler) 
    6642   { 
     6646  _getListenerIndex : function(Element, type, handler, scope) 
     6647  { 
     6648    // determine application scope 
     6649    scope = scope ? scope : Element; 
     6650 
    66436651    for ( var i = 0, m = HTMLArea.Events.listeners.length; i < m; i++ ) 
    66446652    { 
    66456653      var L = HTMLArea.Events.listeners[i]; 
    6646       if ( L && L[0] == Element && L[1] == type && L[2] == handler) 
     6654      if ( L && L[0] == Element && L[1] == type && L[2] == handler && L[4] == scope ) 
    66476655      { 
    66486656        return i; 
     
    66716679 
    66726680  /** 
    6673    * Find index of the DOM0 listener with the couple Element + type 
     6681   * Find index of the DOM0 handler with the couple Element + type 
    66746682   * @param {HTMLElement} Element Element reference 
    66756683   * @param {string}      type    Event type to search 
    6676    * @return {integer} Index in the DOM0 listeners array 
     6684   * @return {integer} Index in the DOM0 handlers array 
    66776685   * @private 
    66786686   */ 
Note: See TracChangeset for help on using the changeset viewer.