Home / Function/ createSetupContext() — vue Function Reference

createSetupContext() — vue Function Reference

Architecture documentation for the createSetupContext() function in apiSetup.ts from the vue codebase.

Entity Profile

Dependency Diagram

graph TD
  1cce23c5_c59e_9843_86a6_04dfc6049dcd["createSetupContext()"]
  0172bfc6_ac03_78a5_d338_b37f7a86af7a["initSetup()"]
  0172bfc6_ac03_78a5_d338_b37f7a86af7a -->|calls| 1cce23c5_c59e_9843_86a6_04dfc6049dcd
  fbb43fd6_617f_8eb0_0af9_9062fbf68d3e["getContext()"]
  fbb43fd6_617f_8eb0_0af9_9062fbf68d3e -->|calls| 1cce23c5_c59e_9843_86a6_04dfc6049dcd
  5cee52f7_79bb_2c7c_c725_f0cd5a668b84["syncSetupProxy()"]
  1cce23c5_c59e_9843_86a6_04dfc6049dcd -->|calls| 5cee52f7_79bb_2c7c_c725_f0cd5a668b84
  36bceb11_f431_e247_eb62_b50489d7fd06["initSlotsProxy()"]
  1cce23c5_c59e_9843_86a6_04dfc6049dcd -->|calls| 36bceb11_f431_e247_eb62_b50489d7fd06
  0c0e51d9_10d5_5aee_bedb_8decee4220fe["proxyWithRefUnwrap()"]
  1cce23c5_c59e_9843_86a6_04dfc6049dcd -->|calls| 0c0e51d9_10d5_5aee_bedb_8decee4220fe
  style 1cce23c5_c59e_9843_86a6_04dfc6049dcd fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

src/v3/apiSetup.ts lines 87–123

function createSetupContext(vm: Component): SetupContext {
  let exposeCalled = false
  return {
    get attrs() {
      if (!vm._attrsProxy) {
        const proxy = (vm._attrsProxy = {})
        def(proxy, '_v_attr_proxy', true)
        syncSetupProxy(proxy, vm.$attrs, emptyObject, vm, '$attrs')
      }
      return vm._attrsProxy
    },
    get listeners() {
      if (!vm._listenersProxy) {
        const proxy = (vm._listenersProxy = {})
        syncSetupProxy(proxy, vm.$listeners, emptyObject, vm, '$listeners')
      }
      return vm._listenersProxy
    },
    get slots() {
      return initSlotsProxy(vm)
    },
    emit: bind(vm.$emit, vm) as any,
    expose(exposed?: Record<string, any>) {
      if (__DEV__) {
        if (exposeCalled) {
          warn(`expose() should be called only once per setup().`, vm)
        }
        exposeCalled = true
      }
      if (exposed) {
        Object.keys(exposed).forEach(key =>
          proxyWithRefUnwrap(vm, exposed, key)
        )
      }
    }
  }
}

Domain

Subdomains

Frequently Asked Questions

What does createSetupContext() do?
createSetupContext() is a function in the vue codebase.
What does createSetupContext() call?
createSetupContext() calls 3 function(s): initSlotsProxy, proxyWithRefUnwrap, syncSetupProxy.
What calls createSetupContext()?
createSetupContext() is called by 2 function(s): getContext, initSetup.

Analyze Your Own Codebase

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

Try Supermodel Free