fix(ssr): fix double escaping of staticClass values (#7859) (#8037)

This commit is contained in:
Haoqun Jiang 2018-08-21 05:49:18 +08:00 committed by Evan You
parent 59860b0a75
commit c21b89ebed
2 changed files with 15 additions and 1 deletions

View File

@ -92,7 +92,7 @@ export function genClassSegments (
classBinding: ?string
): Array<StringSegment> {
if (staticClass && !classBinding) {
return [{ type: RAW, value: ` class=${staticClass}` }]
return [{ type: RAW, value: ` class="${JSON.parse(staticClass)}"` }]
} else {
return [{
type: EXPRESSION,

View File

@ -1245,6 +1245,20 @@ describe('SSR: renderToString', () => {
})
})
// #7859
it('should not double escape class values', done => {
renderVmWithOptions({
template: `
<div>
<div class="a\nb"></div>
</div>
`
}, result => {
expect(result).toContain(`<div class="a\nb"></div>`)
done()
})
})
it('should expose ssr helpers on functional context', done => {
let called = false
renderVmWithOptions({