Skip to content

Commit

Permalink
fix(ssr): fix double escaping of staticClass values (vuejs#7859)
Browse files Browse the repository at this point in the history
  • Loading branch information
haoqunjiang committed Apr 16, 2018
1 parent 8cc7eae commit 3d440a4
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 @@ -1211,6 +1211,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 3d440a4

Please sign in to comment.