prototype: Improve performance of String.prototype.escapeHTML by using a cached div and text node. Closes #6937.
This commit is contained in:
parent
8ea007df28
commit
c556c89627
@ -1,5 +1,7 @@
|
||||
*SVN*
|
||||
|
||||
* Improve performance of String.prototype.escapeHTML by using a cached div and text node. Closes #6937. [altblue]
|
||||
|
||||
* Make setStyle() with opacity: 0 in Internet Explorer work correctly. [Thomas Fuchs]
|
||||
|
||||
* Form.Element.activate shouldn't raise an exception when the form or field is hidden. [sam]
|
||||
|
@ -66,10 +66,9 @@ Object.extend(String.prototype, {
|
||||
},
|
||||
|
||||
escapeHTML: function() {
|
||||
var div = document.createElement('div');
|
||||
var text = document.createTextNode(this);
|
||||
div.appendChild(text);
|
||||
return div.innerHTML;
|
||||
var self = arguments.callee;
|
||||
self.text.data = this;
|
||||
return self.div.innerHTML;
|
||||
},
|
||||
|
||||
unescapeHTML: function() {
|
||||
@ -152,6 +151,13 @@ String.prototype.gsub.prepareReplacement = function(replacement) {
|
||||
|
||||
String.prototype.parseQuery = String.prototype.toQueryParams;
|
||||
|
||||
Object.extend(String.prototype.escapeHTML, {
|
||||
div: document.createElement('div'),
|
||||
text: document.createTextNode('')
|
||||
});
|
||||
|
||||
with (String.prototype.escapeHTML) div.appendChild(text);
|
||||
|
||||
var Template = Class.create();
|
||||
Template.Pattern = /(^|.|\r|\n)(#\{(.*?)\})/;
|
||||
Template.prototype = {
|
||||
|
Loading…
Reference in New Issue
Block a user