Skip to content

Commit b8e4253

Browse files
committed
use ternay rather than property lookup
1 parent ac43a1b commit b8e4253

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

packages/react-dom/src/server/ReactDOMServerFormatConfig.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -84,19 +84,14 @@ const startModuleSrc = stringToPrecomputedChunk('<script type="module" src="');
8484
const endAsyncScript = stringToPrecomputedChunk('" async=""></script>');
8585

8686
const scriptRegex = /(<\/|<)(s)(cript)/gi;
87-
const substitutions = {
88-
s: '\\u0073',
89-
S: '\\u0053',
90-
};
87+
const scriptReplacer = (match, prefix, s, suffix) =>
88+
`${prefix}${s === 's' ? '\\u0073' : '\\u0053'}${suffix}`;
9189

9290
function escapeBootstrapScriptContent(scriptText) {
9391
if (__DEV__) {
9492
checkHtmlStringCoercion(scriptText);
9593
}
96-
return ('' + scriptText).replace(
97-
scriptRegex,
98-
(match, prefix, s, suffix) => `${prefix}${substitutions[s]}${suffix}`,
99-
);
94+
return ('' + scriptText).replace(scriptRegex, scriptReplacer);
10095
}
10196

10297
// Allows us to keep track of what we've already written so we can refer back to it.

0 commit comments

Comments
 (0)