Fix `escapeHTML` in Chrome by using a more strict check.

This commit is contained in:
Juriy Zaytsev 2009-03-22 01:12:45 -04:00
parent dee8a1010c
commit fa15f212fa
2 changed files with 4 additions and 2 deletions

View File

@ -1,3 +1,5 @@
* Make test for `escapeHTML`/`unescapeHTML` more strict. (Chrome 1.x escapes "<" and "&" with `innerHTML`, but not ">") (kangax)
* Remove another sniffing from one of DOM tests. Fixes last IE8 failure. (kangax)
* `Element.extend` now takes care of IE8 bug when HTMLAppletElement and HTMLObjectElement objects do not inherit from `Element.prototype`. (kangax)

View File

@ -444,13 +444,13 @@ Object.extend(String.prototype.escapeHTML, {
String.prototype.escapeHTML.div.appendChild(String.prototype.escapeHTML.text);
if ('<\n'.escapeHTML() !== '&lt;\n') {
if ('<\n>'.escapeHTML() !== '&lt;\n&gt;') {
String.prototype.escapeHTML = function() {
return this.replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;');
}
}
if ('&lt;\n'.unescapeHTML() !== '<\n') {
if ('&lt;\n&gt;'.unescapeHTML() !== '<\n>') {
String.prototype.unescapeHTML = function() {
return this.stripTags().replace(/&lt;/g,'<').replace(/&gt;/g,'>').replace(/&amp;/g,'&');
}