From 4dd99db37843a010cfc6afa6f94249262762207c Mon Sep 17 00:00:00 2001 From: Haoqun Jiang Date: Tue, 21 Aug 2018 05:49:18 +0800 Subject: [PATCH] fix(ssr): fix double escaping of staticClass values (#7859) (#8037) --- 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 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 865ebd6a8b..6dbf5a28ad 100644 --- a/test/ssr/ssr-string.spec.js +++ b/test/ssr/ssr-string.spec.js @@ -1245,6 +1245,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({