Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ssr): renderToString cannot render comment #9128

Merged
merged 3 commits into from Dec 12, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/server/optimizing-compiler/codegen.js
Expand Up @@ -225,7 +225,11 @@ function nodesToSegments (
} else if (c.type === 2) {
segments.push({ type: INTERPOLATION, value: c.expression })
} else if (c.type === 3) {
segments.push({ type: RAW, value: escape(c.text) })
let text = escape(c.text)
if (c.isComment) {
text = '<!--' + text + '-->'
}
segments.push({ type: RAW, value: text })
}
}
return segments
Expand Down
13 changes: 13 additions & 0 deletions test/unit/modules/server-compiler/compiler-options.spec.js
@@ -0,0 +1,13 @@
import { ssrCompile } from 'web/server/compiler'

describe('ssrCompile options', () => {
it('comments', () => {
const compiled = ssrCompile(`
<div>
<!-- test comments -->
</div>
`, { comments: true })

expect(compiled.render).toContain('<!-- test comments -->')
})
})