diff --git a/src/platforms/web/compiler/modules/class.js b/src/platforms/web/compiler/modules/class.js index ffdca250991..31652e2fee1 100644 --- a/src/platforms/web/compiler/modules/class.js +++ b/src/platforms/web/compiler/modules/class.js @@ -22,7 +22,7 @@ function transformNode (el: ASTElement, options: CompilerOptions) { } } if (staticClass) { - el.staticClass = JSON.stringify(staticClass) + el.staticClass = JSON.stringify(staticClass.replace(/\s+/g, ' ')) } const classBinding = getBindingAttr(el, 'class', false /* getStatic */) if (classBinding) { diff --git a/test/ssr/ssr-string.spec.js b/test/ssr/ssr-string.spec.js index 5300bbfefa5..4fb4a531606 100644 --- a/test/ssr/ssr-string.spec.js +++ b/test/ssr/ssr-string.spec.js @@ -1211,6 +1211,37 @@ describe('SSR: renderToString', () => { }) }) + // #7859 + it('should remove and trim newlines in class attributes', done => { + renderVmWithOptions({ + template: ` +