Home / File/ show.ts — vue Source File

show.ts — vue Source File

Architecture documentation for show.ts, a typescript file in the vue codebase. 3 imports, 1 dependents.

File typescript WebPlatform WebRuntime 3 imports 1 dependents 4 functions

Entity Profile

Dependency Diagram

graph LR
  6b6b31ee_7b0e_9602_d29d_c326d873a3e2["show.ts"]
  973389ac_8625_30a3_53ce_b1b48fae58c5["vnode"]
  6b6b31ee_7b0e_9602_d29d_c326d873a3e2 --> 973389ac_8625_30a3_53ce_b1b48fae58c5
  ba925ef2_b0f4_efe3_c23d_fe293c46b2c1["vnode"]
  6b6b31ee_7b0e_9602_d29d_c326d873a3e2 --> ba925ef2_b0f4_efe3_c23d_fe293c46b2c1
  28e31aee_7aad_a843_6c46_695ab9c05478["transition"]
  6b6b31ee_7b0e_9602_d29d_c326d873a3e2 --> 28e31aee_7aad_a843_6c46_695ab9c05478
  75e9abae_441c_ea84_6744_7c3ef7799d18["index.ts"]
  75e9abae_441c_ea84_6744_7c3ef7799d18 --> 6b6b31ee_7b0e_9602_d29d_c326d873a3e2
  style 6b6b31ee_7b0e_9602_d29d_c326d873a3e2 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import VNode from 'core/vdom/vnode'
import type { VNodeDirective, VNodeWithData } from 'types/vnode'
import { enter, leave } from 'web/runtime/modules/transition'

// recursively search for possible transition defined inside the component root
function locateNode(vnode: VNode | VNodeWithData): VNodeWithData {
  // @ts-expect-error
  return vnode.componentInstance && (!vnode.data || !vnode.data.transition)
    ? locateNode(vnode.componentInstance._vnode!)
    : vnode
}

export default {
  bind(el: any, { value }: VNodeDirective, vnode: VNodeWithData) {
    vnode = locateNode(vnode)
    const transition = vnode.data && vnode.data.transition
    const originalDisplay = (el.__vOriginalDisplay =
      el.style.display === 'none' ? '' : el.style.display)
    if (value && transition) {
      vnode.data.show = true
      enter(vnode, () => {
        el.style.display = originalDisplay
      })
    } else {
      el.style.display = value ? originalDisplay : 'none'
    }
  },

  update(el: any, { value, oldValue }: VNodeDirective, vnode: VNodeWithData) {
    /* istanbul ignore if */
    if (!value === !oldValue) return
    vnode = locateNode(vnode)
    const transition = vnode.data && vnode.data.transition
    if (transition) {
      vnode.data.show = true
      if (value) {
        enter(vnode, () => {
          el.style.display = el.__vOriginalDisplay
        })
      } else {
        leave(vnode, () => {
          el.style.display = 'none'
        })
      }
    } else {
      el.style.display = value ? el.__vOriginalDisplay : 'none'
    }
  },

  unbind(
    el: any,
    binding: VNodeDirective,
    vnode: VNodeWithData,
    oldVnode: VNodeWithData,
    isDestroy: boolean
  ) {
    if (!isDestroy) {
      el.style.display = el.__vOriginalDisplay
    }
  }
}

Domain

Subdomains

Dependencies

  • transition
  • vnode
  • vnode

Frequently Asked Questions

What does show.ts do?
show.ts is a source file in the vue codebase, written in typescript. It belongs to the WebPlatform domain, WebRuntime subdomain.
What functions are defined in show.ts?
show.ts defines 4 function(s): default.bind, default.unbind, default.update, locateNode.
What does show.ts depend on?
show.ts imports 3 module(s): transition, vnode, vnode.
What files import show.ts?
show.ts is imported by 1 file(s): index.ts.
Where is show.ts in the architecture?
show.ts is located at src/platforms/web/runtime/directives/show.ts (domain: WebPlatform, subdomain: WebRuntime, directory: src/platforms/web/runtime/directives).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free