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
  6827e187_9a52_5423_0fdc_05675ae269f2["createSetupContext()"]
  87ac0b39_9319_5c07_1390_906641a5c4fe["initSetup()"]
  87ac0b39_9319_5c07_1390_906641a5c4fe -->|calls| 6827e187_9a52_5423_0fdc_05675ae269f2
  a9fff689_3261_6c15_1afe_9ac9a797d119["getContext()"]
  a9fff689_3261_6c15_1afe_9ac9a797d119 -->|calls| 6827e187_9a52_5423_0fdc_05675ae269f2
  0c8dcb74_d1a6_69b8_fa50_1c0794b7cc11["syncSetupProxy()"]
  6827e187_9a52_5423_0fdc_05675ae269f2 -->|calls| 0c8dcb74_d1a6_69b8_fa50_1c0794b7cc11
  cfcd0851_d142_c3a3_e9a9_538ca28c7918["initSlotsProxy()"]
  6827e187_9a52_5423_0fdc_05675ae269f2 -->|calls| cfcd0851_d142_c3a3_e9a9_538ca28c7918
  0dff7671_dbca_28ee_2e55_169d9e03ef4c["proxyWithRefUnwrap()"]
  6827e187_9a52_5423_0fdc_05675ae269f2 -->|calls| 0dff7671_dbca_28ee_2e55_169d9e03ef4c
  style 6827e187_9a52_5423_0fdc_05675ae269f2 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