diff --git a/src/server/optimizing-compiler/optimizer.js b/src/server/optimizing-compiler/optimizer.js index 82ac880ef56..1a671803caa 100644 --- a/src/server/optimizing-compiler/optimizer.js +++ b/src/server/optimizing-compiler/optimizer.js @@ -55,7 +55,7 @@ function walk (node: ASTNode, isRoot?: boolean) { if (node.ifConditions) { for (let i = 1, l = node.ifConditions.length; i < l; i++) { const block = node.ifConditions[i].block - walk(block) + walk(block, isRoot) check(block) } } diff --git a/test/ssr/ssr-string.spec.js b/test/ssr/ssr-string.spec.js index 7e07ad112fe..e52d34ffe5d 100644 --- a/test/ssr/ssr-string.spec.js +++ b/test/ssr/ssr-string.spec.js @@ -989,6 +989,17 @@ describe('SSR: renderToString', () => { done() }) }) + + // #6907 + it('should not optimize root if conditions', done => { + renderVmWithOptions({ + data: { foo: 123 }, + template: `` + }, res => { + expect(res).toBe(``) + done() + }) + }) }) function renderVmWithOptions (options, cb) {