From 3d440a49ca80eb35615931ed03f44c88dd9fcb9b Mon Sep 17 00:00:00 2001 From: Haoqun Jiang Date: Tue, 17 Apr 2018 00:22:27 +0800 Subject: [PATCH] fix(ssr): fix double escaping of staticClass values (#7859) --- src/server/optimizing-compiler/modules.js | 2 +- test/ssr/ssr-string.spec.js | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/server/optimizing-compiler/modules.js b/src/server/optimizing-compiler/modules.js index 69a7be87390..821f0e2b064 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 5300bbfefa5..c1d432517e0 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({