All files / compiler-ssr/src/transforms ssrTransformTransitionGroup.ts

100% Statements 17/17
100% Branches 4/4
100% Functions 1/1
100% Lines 17/17

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 4230x 30x   30x       4x 4x 2x   1x 1x 1x   1x                       1x 1x 1x     1x 1x 1x       2x      
import { ComponentNode, findProp, NodeTypes } from '@vue/compiler-dom'
import { processChildren, SSRTransformContext } from '../ssrCodegenTransform'
 
export function ssrProcessTransitionGroup(
  node: ComponentNode,
  context: SSRTransformContext
) {
  const tag = findProp(node, 'tag')
  if (tag) {
    if (tag.type === NodeTypes.DIRECTIVE) {
      // dynamic :tag
      context.pushStringPart(`<`)
      context.pushStringPart(tag.exp!)
      context.pushStringPart(`>`)
 
      processChildren(
        node.children,
        context,
        false,
        /**
         * TransitionGroup has the special runtime behavior of flattening and
         * concatenating all children into a single fragment (in order for them to
         * be patched using the same key map) so we need to account for that here
         * by disabling nested fragment wrappers from being generated.
         */
        true
      )
      context.pushStringPart(`</`)
      context.pushStringPart(tag.exp!)
      context.pushStringPart(`>`)
    } else {
      // static tag
      context.pushStringPart(`<${tag.value!.content}>`)
      processChildren(node.children, context, false, true)
      context.pushStringPart(`</${tag.value!.content}>`)
    }
  } else {
    // fragment
    processChildren(node.children, context, true, true)
  }
}