Skip to content

Commit

Permalink
Replace browser sniffing with capability detection in IE fork of Stri…
Browse files Browse the repository at this point in the history
…ng#unescapeHTML. [#168 state:resolved]
  • Loading branch information
savetheclocktower committed Jun 26, 2008
1 parent be24bf9 commit 0755dbd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG
@@ -1,3 +1,5 @@
* Replace browser sniffing with capability detection in IE fork of String#unescapeHTML. [kangax]

* Coerce Opera's version string into a number whenever we need to sniff. [Sam Holman, jddalton]

* Amend previous checkin to restrict fix to Opera 9.5. [Andrew Dupont]
Expand Down
7 changes: 4 additions & 3 deletions src/string.js
Expand Up @@ -87,7 +87,7 @@ Object.extend(String.prototype, {
},

unescapeHTML: function() {
var div = new Element('div');
var div = document.createElement('div');
// Safari requires the text nested inside another element to render correctly
div.innerHTML = '<pre>' + this.stripTags() + '</pre>';
div = div.firstChild;
Expand Down Expand Up @@ -226,9 +226,10 @@ Object.extend(String.prototype.escapeHTML, {
text: document.createTextNode('')
});

String.prototype.escapeHTML.container.appendChild(String.prototype.escapeHTML.text);
String.prototype.escapeHTML.container.appendChild(
String.prototype.escapeHTML.text);

if (Prototype.Browser.IE) {
if ('1\n2'.unescapeHTML() === '1\r2') {
// IE converts all newlines to carriage returns so we swap them back
String.prototype.unescapeHTML = String.prototype.unescapeHTML.wrap(function(proceed) {
return proceed().replace(/\r/g, '\n')
Expand Down

0 comments on commit 0755dbd

Please sign in to comment.