Skip to content

Commit 576e98f

Browse files
haoqunjianghefeng
authored and
hefeng
committed
fix(ssr): fix double escaping of staticClass values (vuejs#7859) (vuejs#8037)
1 parent ad2c3f8 commit 576e98f

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/server/optimizing-compiler/modules.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ export function genClassSegments (
9292
classBinding: ?string
9393
): Array<StringSegment> {
9494
if (staticClass && !classBinding) {
95-
return [{ type: RAW, value: ` class=${staticClass}` }]
95+
return [{ type: RAW, value: ` class="${JSON.parse(staticClass)}"` }]
9696
} else {
9797
return [{
9898
type: EXPRESSION,

test/ssr/ssr-string.spec.js

+14
Original file line numberDiff line numberDiff line change
@@ -1245,6 +1245,20 @@ describe('SSR: renderToString', () => {
12451245
})
12461246
})
12471247

1248+
// #7859
1249+
it('should not double escape class values', done => {
1250+
renderVmWithOptions({
1251+
template: `
1252+
<div>
1253+
<div class="a\nb"></div>
1254+
</div>
1255+
`
1256+
}, result => {
1257+
expect(result).toContain(`<div class="a\nb"></div>`)
1258+
done()
1259+
})
1260+
})
1261+
12481262
it('should expose ssr helpers on functional context', done => {
12491263
let called = false
12501264
renderVmWithOptions({

0 commit comments

Comments
 (0)