1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-02-11 11:25:47 +01:00

Death to E4X and stuff.

This commit is contained in:
Kris Maglione
2012-11-30 19:58:25 -08:00
parent 9305f1a6a4
commit dff13c70fc
2 changed files with 42 additions and 46 deletions

View File

@@ -1501,11 +1501,14 @@ var DOM = Class("DOM", {
* entities.
*
* @param {string} str
* @param {boolean} simple If true, only escape for the simple case
* of text nodes.
* @returns {string}
*/
escapeHTML: function escapeHTML(str) {
escapeHTML: function escapeHTML(str, simple) {
let map = { "'": "&apos;", '"': "&quot;", "%": "&#x25;", "&": "&amp;", "<": "&lt;", ">": "&gt;" };
return str.replace(/['"&<>]/g, function (m) map[m]);
let regexp = simple ? /[<>]/g : /['"&<>]/g;
return str.replace(regexp, function (m) map[m]);
},
/**