escapeHtml() — react Function Reference
Architecture documentation for the escapeHtml() function in escapeTextForBrowser.js from the react codebase.
Entity Profile
Dependency Diagram
graph TD 65324f68_ff50_709d_fb49_49e9e028978d["escapeHtml()"] 12a08100_717c_694e_2f9c_24bc208ee2f7["escapeTextForBrowser.js"] 65324f68_ff50_709d_fb49_49e9e028978d -->|defined in| 12a08100_717c_694e_2f9c_24bc208ee2f7 style 65324f68_ff50_709d_fb49_49e9e028978d fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/react-dom-bindings/src/server/escapeTextForBrowser.js lines 53–99
function escapeHtml(string: string) {
if (__DEV__) {
checkHtmlStringCoercion(string);
}
const str = '' + string;
const match = matchHtmlRegExp.exec(str);
if (!match) {
return str;
}
let escape;
let html = '';
let index;
let lastIndex = 0;
for (index = match.index; index < str.length; index++) {
switch (str.charCodeAt(index)) {
case 34: // "
escape = '"';
break;
case 38: // &
escape = '&';
break;
case 39: // '
escape = '''; // modified from escape-html; used to be '''
break;
case 60: // <
escape = '<';
break;
case 62: // >
escape = '>';
break;
default:
continue;
}
if (lastIndex !== index) {
html += str.slice(lastIndex, index);
}
lastIndex = index + 1;
html += escape;
}
return lastIndex !== index ? html + str.slice(lastIndex, index) : html;
}
Domain
Subdomains
Source
Frequently Asked Questions
What does escapeHtml() do?
escapeHtml() is a function in the react codebase, defined in packages/react-dom-bindings/src/server/escapeTextForBrowser.js.
Where is escapeHtml() defined?
escapeHtml() is defined in packages/react-dom-bindings/src/server/escapeTextForBrowser.js at line 53.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free