Skip to content

Commit 41acdc0

Browse files
committed
fix v-html/v-text on root element
1 parent 2f4ad14 commit 41acdc0

File tree

2 files changed

+27
-4
lines changed

2 files changed

+27
-4
lines changed

Diff for: src/server/optimizing-compiler/optimizer.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,7 @@ function walk (node: ASTNode, isRoot?: boolean) {
6060
}
6161
}
6262
if (node.ssrOptimizability == null ||
63-
node.attrsMap['v-html'] ||
64-
node.attrsMap['v-text']
63+
(!isRoot && (node.attrsMap['v-html'] || node.attrsMap['v-text']))
6564
) {
6665
node.ssrOptimizability = optimizability.FULL
6766
} else {

Diff for: test/ssr/ssr-string.spec.js

+26-2
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ describe('SSR: renderToString', () => {
338338
})
339339
})
340340

341-
it('v-html', done => {
341+
it('v-html on root', done => {
342342
renderVmWithOptions({
343343
template: '<div v-html="text"></div>',
344344
data: {
@@ -350,7 +350,7 @@ describe('SSR: renderToString', () => {
350350
})
351351
})
352352

353-
it('v-text', done => {
353+
it('v-text on root', done => {
354354
renderVmWithOptions({
355355
template: '<div v-text="text"></div>',
356356
data: {
@@ -362,6 +362,30 @@ describe('SSR: renderToString', () => {
362362
})
363363
})
364364

365+
it('v-html', done => {
366+
renderVmWithOptions({
367+
template: '<div><div v-html="text"></div></div>',
368+
data: {
369+
text: '<span>foo</span>'
370+
}
371+
}, result => {
372+
expect(result).toContain('<div data-server-rendered="true"><div><span>foo</span></div></div>')
373+
done()
374+
})
375+
})
376+
377+
it('v-text', done => {
378+
renderVmWithOptions({
379+
template: '<div><div v-text="text"></div></div>',
380+
data: {
381+
text: '<span>foo</span>'
382+
}
383+
}, result => {
384+
expect(result).toContain('<div data-server-rendered="true"><div>&lt;span&gt;foo&lt;/span&gt;</div></div>')
385+
done()
386+
})
387+
})
388+
365389
it('child component (hoc)', done => {
366390
renderVmWithOptions({
367391
template: '<child class="foo" :msg="msg"></child>',

0 commit comments

Comments
 (0)