diff --git a/src/server/optimizing-compiler/modules.js b/src/server/optimizing-compiler/modules.js index 69a7be8739..821f0e2b06 100644 --- a/src/server/optimizing-compiler/modules.js +++ b/src/server/optimizing-compiler/modules.js @@ -92,7 +92,7 @@ export function genClassSegments ( classBinding: ?string ): Array { if (staticClass && !classBinding) { - return [{ type: RAW, value: ` class=${staticClass}` }] + return [{ type: RAW, value: ` class="${JSON.parse(staticClass)}"` }] } else { return [{ type: EXPRESSION, diff --git a/test/ssr/ssr-string.spec.js b/test/ssr/ssr-string.spec.js index 5300bbfefa..c1d432517e 100644 --- a/test/ssr/ssr-string.spec.js +++ b/test/ssr/ssr-string.spec.js @@ -1211,6 +1211,20 @@ describe('SSR: renderToString', () => { }) }) + // #7859 + it('should not double escape class values', done => { + renderVmWithOptions({ + template: ` +
+
+
+ ` + }, result => { + expect(result).toContain(`
`) + done() + }) + }) + it('should expose ssr helpers on functional context', done => { let called = false renderVmWithOptions({