Skip to content

Commit

Permalink
fix(ssr): fix double escaping of staticClass values (vuejs#7859) (vue…
Browse files Browse the repository at this point in the history
  • Loading branch information
haoqunjiang authored and aJean committed Aug 19, 2020
1 parent 6a4766f commit 4dd99db
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 4dd99db

Please sign in to comment.