MCPcopy
hub / github.com/vuejs/core / transformOnce

Function transformOnce

packages/compiler-core/src/transforms/vOnce.ts:8–28  ·  view source on GitHub ↗
(node, context)

Source from the content-addressed store, hash-verified

6const seen = new WeakSet()
7
8export const transformOnce: NodeTransform = (node, context) => {
9 if (node.type === NodeTypes.ELEMENT && findDir(node, 'once', true)) {
10 if (seen.has(node) || context.inVOnce || context.inSSR) {
11 return
12 }
13 seen.add(node)
14 context.inVOnce = true
15 context.helper(SET_BLOCK_TRACKING)
16 return () => {
17 context.inVOnce = false
18 const cur = context.currentNode as ElementNode | IfNode | ForNode
19 if (cur.codegenNode) {
20 cur.codegenNode = context.cache(
21 cur.codegenNode,
22 true /* isVNode */,
23 true /* inVOnce */,
24 )
25 }
26 }
27 }
28}

Callers

nothing calls this directly

Calls 4

findDirFunction · 0.90
hasMethod · 0.80
cacheMethod · 0.80
helperMethod · 0.65

Tested by

no test coverage detected