Browse Source

fix root node optimizability

dev
Evan You 8 years ago
parent
commit
7cf1e654a6
  1. 2
      src/server/optimizing-compiler/codegen.js
  2. 22
      src/server/optimizing-compiler/optimizer.js

2
src/server/optimizing-compiler/codegen.js

@ -99,7 +99,7 @@ function genStringElement (el, state, stringifyChildren) {
const children = genSSRChildren(el, state, true)
return `_ssrNode(${
flattenSegments(elementToOpenTagSegments(el, state))
}","${el.tag}"${
},"${el.tag}"${
children ? `,${children}` : ''
})`
}

22
src/server/optimizing-compiler/optimizer.js

@ -35,28 +35,28 @@ function walk (node: ASTNode, isRoot?: boolean) {
return
}
// root node or nodes with custom directives should always be a VNode
if (isRoot || hasCustomDirective(node)) {
const selfUnoptimizable = isRoot || hasCustomDirective(node)
const check = child => {
if (child.ssrOptimizability !== optimizability.FULL) {
node.ssrOptimizability = selfUnoptimizable
? optimizability.PARTIAL
: optimizability.SELF
}
}
if (selfUnoptimizable) {
node.ssrOptimizability = optimizability.CHILDREN
}
if (node.type === 1) {
for (let i = 0, l = node.children.length; i < l; i++) {
const child = node.children[i]
walk(child)
if (child.ssrOptimizability !== optimizability.FULL) {
node.ssrOptimizability = node.ssrOptimizability === optimizability.CHILDREN
? optimizability.PARTIAL
: optimizability.SELF
}
check(child)
}
if (node.ifConditions) {
for (let i = 1, l = node.ifConditions.length; i < l; i++) {
const block = node.ifConditions[i].block
walk(block)
if (block.ssrOptimizability !== optimizability.FULL) {
node.ssrOptimizability = node.ssrOptimizability === optimizability.CHILDREN
? optimizability.PARTIAL
: optimizability.SELF
}
check(block)
}
}
if (node.ssrOptimizability == null) {

Loading…
Cancel
Save