While going through the source for Remy Sharp’s demo of Simple Drag and Drop, I found this function:
function entities(s) {
var e = {
'"' : '"',
'&' : '&',
'<' : '<',
'>' : '>'
};
return s.replace(/["&<>]/g, function (m) {
return e[m];
});
}
From what I see, it just replaces ” or & or < or > with itself. So there is no need for that function.
How am I wrong?
UPDATE:
Source can be viewed by clicking ‘View Source’ at the end of the page.
I looked the source of the page in Chrome with
Ctrl+U, and this is what I found:This, obviously, does something — namely, it replaces special characters with an escaped form.
The reason that you saw what you did is that the source you’re viewing on the “view source” page is being rendered in HTML. Thus, when the source’s
"string is rendered on the “view source” page, it shows up on the HTML page as". HTML5Deoms really should escape the ampersands on their view-source pages like&quot;so that it will show up on rendered source page correctly as", but they don’t do that.