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

Ticket #6937: escapeHTML-optimization-rev5871.diff

File escapeHTML-optimization-rev5871.diff, 0.8 kB (added by altblue, 2 years ago)
  • src/string.js

    old new  
    22  return value == null ? '' : String(value); 
    33} 
    44 
     5String.escapeHTMLDiv  = document.createElement('div'); 
     6String.escapeHTMLText = document.createTextNode(''); 
     7String.escapeHTMLDiv.appendChild(String.escapeHTMLText); 
     8 
    59Object.extend(String.prototype, { 
    610  gsub: function(pattern, replacement) { 
    711    var result = '', source = this, match; 
     
    6670  }, 
    6771 
    6872  escapeHTML: function() { 
    69     var div = document.createElement('div'); 
    70     var text = document.createTextNode(this); 
    71     div.appendChild(text); 
    72     return div.innerHTML; 
     73    String.escapeHTMLText.data = this; 
     74    return String.escapeHTMLDiv.innerHTML; 
    7375  }, 
    7476 
    7577  unescapeHTML: function() {