Closed qfox closed 8 years ago
In lodash there is simple check before replacing:
var reUnescapedHtml = /[&<>"'`]/g, reHasUnescapedHtml = RegExp(reUnescapedHtml.source); function escape(string) { string = toString(string); return (string && reHasUnescapedHtml.test(string)) ? string.replace(reUnescapedHtml, escapeHtmlChar) : string; }
Guess we should try something like that:
var hasEntities = /[&<>]/; exports.xmlEscape = function(str) { str = str + ''; hasEntities.test(str) && (str = str .replace(/&/g, '&') .replace(/</g, '<') .replace(/>/g, '>')); return str; };
So, where is the PR? ;)
We need benchmark result.
We don’t use RegExp after https://github.com/bem/bem-xjst/pull/328
In lodash there is simple check before replacing:
Guess we should try something like that: