Skip to content

Commit

Permalink
fix(ssr): fix double escaping of staticClass values (#7859) (#8037)
Browse files Browse the repository at this point in the history
  • Loading branch information
haoqunjiang authored and yyx990803 committed Aug 20, 2018
1 parent 59860b0 commit c21b89e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/server/optimizing-compiler/modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
14 changes: 14 additions & 0 deletions test/ssr/ssr-string.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down

0 comments on commit c21b89e

Please sign in to comment.