Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 4094

Show
Ignore:
Timestamp:
03/29/06 00:00:29 (3 years ago)
Author:
sam
Message:

prototype: Cache methods added to DOM elements with Element.extend to prevent memory leaks in IE. Closes #4465.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • spinoffs/prototype/CHANGELOG

    r4062 r4094  
    11*SVN* 
     2 
     3* Cache methods added to DOM elements with Element.extend to prevent memory leaks in IE. Closes #4465. [jaen@laborint.com, sam] 
    24 
    35* 1.5.0_pre1* (March 26, 2006) 
  • spinoffs/prototype/src/dom.js

    r3792 r4094  
    2828   
    2929  if (!element._extended && element.tagName && element != window) { 
    30     var methods = Element.Methods
     30    var methods = Element.Methods, cache = Element.extend.cache
    3131    for (property in methods) { 
    3232      var value = methods[property]; 
    3333      if (typeof value == 'function') 
    34         element[property] = value.bind(null, element); 
     34        element[property] = cache.findOrStore(value); 
    3535    } 
    3636  } 
     
    3838  element._extended = true; 
    3939  return element; 
     40} 
     41 
     42Element.extend.cache = { 
     43  findOrStore: function(value) { 
     44    return this[value] = this[value] || function() { 
     45      return value.apply(null, [this].concat($A(arguments))); 
     46    } 
     47  } 
    4048} 
    4149