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

Changeset 6046

Show
Ignore:
Timestamp:
01/27/07 18:33:03 (2 years ago)
Author:
sam
Message:

prototype: Improve performance of String.prototype.escapeHTML by using a cached div and text node. Closes #6937.

Files:

Legend:

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

    r6002 r6046  
    11*SVN* 
     2 
     3* Improve performance of String.prototype.escapeHTML by using a cached div and text node.  Closes #6937.  [altblue] 
    24 
    35* Make setStyle() with opacity: 0 in Internet Explorer work correctly.  [Thomas Fuchs] 
  • spinoffs/prototype/trunk/src/string.js

    r5736 r6046  
    6767 
    6868  escapeHTML: function() { 
    69     var div = document.createElement('div'); 
    70     var text = document.createTextNode(this); 
    71     div.appendChild(text); 
    72     return div.innerHTML; 
     69    var self = arguments.callee; 
     70    self.text.data = this; 
     71    return self.div.innerHTML; 
    7372  }, 
    7473 
     
    153152String.prototype.parseQuery = String.prototype.toQueryParams; 
    154153 
     154Object.extend(String.prototype.escapeHTML, { 
     155  div:  document.createElement('div'), 
     156  text: document.createTextNode('') 
     157}); 
     158 
     159with (String.prototype.escapeHTML) div.appendChild(text); 
     160 
    155161var Template = Class.create(); 
    156162Template.Pattern = /(^|.|\r|\n)(#\{(.*?)\})/;