2019-10-23 21:57:40 +00:00
|
|
|
import { NodeTransform } from '../transform'
|
|
|
|
import { findDir } from '../utils'
|
|
|
|
import { NodeTypes } from '../ast'
|
|
|
|
import { SET_BLOCK_TRACKING } from '../runtimeHelpers'
|
2019-10-09 21:32:58 +00:00
|
|
|
|
2019-10-23 21:57:40 +00:00
|
|
|
export const transformOnce: NodeTransform = (node, context) => {
|
|
|
|
if (node.type === NodeTypes.ELEMENT && findDir(node, 'once', true)) {
|
|
|
|
context.helper(SET_BLOCK_TRACKING)
|
|
|
|
return () => {
|
|
|
|
if (node.codegenNode) {
|
|
|
|
node.codegenNode = context.cache(node.codegenNode, true /* isVNode */)
|
|
|
|
}
|
|
|
|
}
|
2019-10-09 21:32:58 +00:00
|
|
|
}
|
|
|
|
}
|