-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ssrLoadModule html-escapes single quote to ' #15662
Comments
Hey, could this be actually the legitimate html escape done by https://stackblitz.com/edit/github-nr2ezh?file=repro.js /*
node ./repro.js
{
result: '<div style="background-image:url('/anything')"></div>'
}
*/
async function main() {
const React = await import('react');
const ReactDOMServer = await import('react-dom/server');
const el = React.createElement('div', {
style: { backgroundImage: `url('/anything')` },
});
const result = ReactDOMServer.renderToString(el);
console.log({ result });
}
main(); Btw, there is react ssr template here https://github.com/bluwy/create-vite-extra/tree/master/template-ssr-react-ts so it might help when you want to investigate issues based on bare bone setup without frameworks. |
Hello @mkilpatrick. Please provide a minimal reproduction using a GitHub repository or StackBlitz. Issues marked with |
It happens when calling transformIndexHtml on html where the app-html has already been replaced. The result is a little different from my original issue description. You can see that the server html is missing the background-image property completely. Diff here. |
Thanks for clarifying the issue with reproduction. According to #15345 (comment), currently it's not intended to apply For now, I added "pending triage" label back since this specific style url issue might have a different cause. I tried to simplify the issue to https://stackblitz.com/edit/vitejs-vite-hggc63?file=repro.mjs import { createServer } from 'vite';
const server = await createServer();
const html = `
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
</head>
<body>
<div style="background-image:url(/vite.svg)"></div>
</body>
</html>
`;
const html2 = await server.transformIndexHtml('/', html); |
Describe the bug
When calling ssrLoadModule the resulting HTML, when passed to ReactDOMServer.renderToString, results in
'
(single quote) being html-escaped to'
. It results in the error:Warning: Prop
style
did not match. Server: "" Client: "background-image:url('/src/assets/images/tacos-1.avif')"Actual code
Server-rendered HTML
Reproduction
N/A
Steps to reproduce
No response
System Info
Used Package Manager
npm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: