Browse Source

fix optimizer isStatic check

dev
Evan You 9 years ago
parent
commit
b67143a5b8
  1. 8
      src/compiler/optimizer.js

8
src/compiler/optimizer.js

@ -24,7 +24,7 @@ export function optimize (root: ?ASTElement, options: CompilerOptions) {
markStaticRoots(root) markStaticRoots(root)
} }
function markStatic (node) { function markStatic (node: ASTNode) {
node.static = isStatic(node) node.static = isStatic(node)
if (node.type === 1) { if (node.type === 1) {
for (let i = 0, l = node.children.length; i < l; i++) { for (let i = 0, l = node.children.length; i < l; i++) {
@ -37,7 +37,7 @@ function markStatic (node) {
} }
} }
function markStaticRoots (node) { function markStaticRoots (node: ASTNode) {
if (node.type === 1 && (node.once || node.static)) { if (node.type === 1 && (node.once || node.static)) {
node.staticRoot = true node.staticRoot = true
return return
@ -50,7 +50,7 @@ function markStaticRoots (node) {
} }
const isStaticKey = makeMap( const isStaticKey = makeMap(
'tag,attrsList,attrsMap,plain,parent,children,' + 'type,tag,attrsList,attrsMap,plain,parent,children,' +
'staticAttrs,staticClass' 'staticAttrs,staticClass'
) )
@ -63,8 +63,8 @@ function isStatic (node: ASTNode): boolean {
} }
return !!(node.pre || ( return !!(node.pre || (
!node.if && !node.for && // not v-if or v-for or v-else !node.if && !node.for && // not v-if or v-for or v-else
isPlatformReservedTag(node.tag) && // not a component
!isBuiltInTag(node.tag) && // not a built-in !isBuiltInTag(node.tag) && // not a built-in
isPlatformReservedTag(node.tag) && // not a component
(node.plain || Object.keys(node).every(isStaticKey)) // no dynamic bindings (node.plain || Object.keys(node).every(isStaticKey)) // no dynamic bindings
)) ))
} }

Loading…
Cancel
Save