Skip to content

Commit da40d42

Browse files
yyx990803hefeng
authored and
hefeng
committed
fix(ssr): should not optimize root if conditions
fix vuejs#6907
1 parent 3012db8 commit da40d42

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/server/optimizing-compiler/optimizer.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ function walk (node: ASTNode, isRoot?: boolean) {
5555
if (node.ifConditions) {
5656
for (let i = 1, l = node.ifConditions.length; i < l; i++) {
5757
const block = node.ifConditions[i].block
58-
walk(block)
58+
walk(block, isRoot)
5959
check(block)
6060
}
6161
}

test/ssr/ssr-string.spec.js

+11
Original file line numberDiff line numberDiff line change
@@ -989,6 +989,17 @@ describe('SSR: renderToString', () => {
989989
done()
990990
})
991991
})
992+
993+
// #6907
994+
it('should not optimize root if conditions', done => {
995+
renderVmWithOptions({
996+
data: { foo: 123 },
997+
template: `<input :type="'text'" v-model="foo">`
998+
}, res => {
999+
expect(res).toBe(`<input type="text" data-server-rendered="true" value="123">`)
1000+
done()
1001+
})
1002+
})
9921003
})
9931004

9941005
function renderVmWithOptions (options, cb) {

0 commit comments

Comments
 (0)