Skip to content

Commit

Permalink
fix(ssr): support rendering comment (#9128)
Browse files Browse the repository at this point in the history
  • Loading branch information
clarkdo authored and yyx990803 committed Dec 12, 2018
1 parent 7075408 commit b06c784
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
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 -->')
})
})

0 comments on commit b06c784

Please sign in to comment.