Changeset 533


Ignore:
Timestamp:
07/22/06 13:31:22 (13 years ago)
Author:
mokhet
Message:

enhance HTMLArea.free(). Take care of hidden TD which are leaking in IE and innerHTML property which must not be null but blank instead

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/htmlarea.js

    r532 r533  
    200200      panels[i].container.className = 'panels ' + i; 
    201201      HTMLArea.freeLater(panels[i], 'container'); 
    202       HTMLArea.freeLater(panels[i], 'div');       
     202      HTMLArea.freeLater(panels[i], 'div'); 
    203203    } 
    204204    // finally store the variable 
    205205    this._panels = panels; 
    206      
     206 
    207207    HTMLArea.freeLater(this, '_textArea'); 
    208208  } 
     
    67126712}; 
    67136713 
    6714 HTMLArea.free = function(obj, prop) 
    6715 { 
    6716   if ( obj && !prop ) 
    6717   { 
    6718     for ( var p in obj ) 
    6719     { 
    6720       HTMLArea.free(obj, p); 
    6721     } 
    6722   } 
    6723   else if ( obj ) 
    6724   { 
     6714/** 
     6715 * Release memory properties from object 
     6716 * @param {object} O (Object)   The object to free memory 
     6717 * @param (string} P (Property) The property to release (optional) 
     6718 * @private 
     6719 */ 
     6720HTMLArea.free = function(O, P) 
     6721{ 
     6722  if ( O && !P ) 
     6723  { 
     6724    for ( var p in O ) 
     6725    { 
     6726      HTMLArea.free(O, p); 
     6727    } 
     6728  } 
     6729  else if ( O ) 
     6730  { 
     6731    // is the try...catch really required here ? 
    67256732    try 
    67266733    { 
    6727       obj[prop] = null; 
    6728     } catch(ex) {} 
     6734      // if the property is innerHTML, null can't be used because it is interpreted as null.toString() 
     6735      // we need to blank it instead 
     6736      if ( P == 'innerHTML' ) 
     6737      { 
     6738        O[P] = ''; 
     6739      } 
     6740      else 
     6741      { 
     6742        // need to unhide TD cells before delete them or they will leak in IE 
     6743        if ( P && O[P] && O[P].tagName && O[P].tagName.toLowerCase() == 'td' ) 
     6744        { 
     6745          O[P].style.display = ''; 
     6746        } 
     6747        O[P] = null; 
     6748      } 
     6749    } catch(x) {} 
    67296750  } 
    67306751}; 
Note: See TracChangeset for help on using the changeset viewer.