fix(compiler): include createTextVNode helper for hoisted static content (fix #465)
This commit is contained in:
parent
f838715b7c
commit
e89d009937
@ -35,7 +35,8 @@ import {
|
|||||||
RESOLVE_COMPONENT,
|
RESOLVE_COMPONENT,
|
||||||
RESOLVE_DIRECTIVE,
|
RESOLVE_DIRECTIVE,
|
||||||
SET_BLOCK_TRACKING,
|
SET_BLOCK_TRACKING,
|
||||||
CREATE_COMMENT
|
CREATE_COMMENT,
|
||||||
|
CREATE_TEXT
|
||||||
} from './runtimeHelpers'
|
} from './runtimeHelpers'
|
||||||
|
|
||||||
type CodegenNode = TemplateChildNode | JSChildNode
|
type CodegenNode = TemplateChildNode | JSChildNode
|
||||||
@ -212,18 +213,11 @@ export function generate(
|
|||||||
// has check cost, but hoists are lifted out of the function - we need
|
// has check cost, but hoists are lifted out of the function - we need
|
||||||
// to provide the helper here.
|
// to provide the helper here.
|
||||||
if (ast.hoists.length) {
|
if (ast.hoists.length) {
|
||||||
push(
|
const staticHelpers = [CREATE_VNODE, CREATE_COMMENT, CREATE_TEXT]
|
||||||
`const _${helperNameMap[CREATE_VNODE]} = Vue.${
|
.filter(helper => ast.helpers.includes(helper))
|
||||||
helperNameMap[CREATE_VNODE]
|
.map(s => `${helperNameMap[s]}: _${helperNameMap[s]}`)
|
||||||
}\n`
|
.join(', ')
|
||||||
)
|
push(`const { ${staticHelpers} } = Vue\n`)
|
||||||
if (ast.helpers.includes(CREATE_COMMENT)) {
|
|
||||||
push(
|
|
||||||
`const _${helperNameMap[CREATE_COMMENT]} = Vue.${
|
|
||||||
helperNameMap[CREATE_COMMENT]
|
|
||||||
}\n`
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user