Skip to content

Commit

Permalink
use ternay rather than property lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
gnoff committed Apr 16, 2022
1 parent ac43a1b commit b8e4253
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions packages/react-dom/src/server/ReactDOMServerFormatConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,19 +84,14 @@ const startModuleSrc = stringToPrecomputedChunk('<script type="module" src="');
const endAsyncScript = stringToPrecomputedChunk('" async=""></script>');

const scriptRegex = /(<\/|<)(s)(cript)/gi;
const substitutions = {
s: '\\u0073',
S: '\\u0053',
};
const scriptReplacer = (match, prefix, s, suffix) =>
`${prefix}${s === 's' ? '\\u0073' : '\\u0053'}${suffix}`;

function escapeBootstrapScriptContent(scriptText) {
if (__DEV__) {
checkHtmlStringCoercion(scriptText);
}
return ('' + scriptText).replace(
scriptRegex,
(match, prefix, s, suffix) => `${prefix}${substitutions[s]}${suffix}`,
);
return ('' + scriptText).replace(scriptRegex, scriptReplacer);
}

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

0 comments on commit b8e4253

Please sign in to comment.