Home / Function/ initExtend() — vue Function Reference

initExtend() — vue Function Reference

Architecture documentation for the initExtend() function in extend.ts from the vue codebase.

Entity Profile

Dependency Diagram

graph TD
  e9415a90_94de_e969_0351_990c46050d05["initExtend()"]
  569ea312_4d3b_007e_7375_5022a3a78a2b["initGlobalAPI()"]
  569ea312_4d3b_007e_7375_5022a3a78a2b -->|calls| e9415a90_94de_e969_0351_990c46050d05
  5b67b159_7ee7_ed13_42a0_e4b5c3befd84["getComponentName()"]
  e9415a90_94de_e969_0351_990c46050d05 -->|calls| 5b67b159_7ee7_ed13_42a0_e4b5c3befd84
  d6eecf16_0b33_9978_9ebb_d8829be93c79["initProps()"]
  e9415a90_94de_e969_0351_990c46050d05 -->|calls| d6eecf16_0b33_9978_9ebb_d8829be93c79
  513e4cf1_6313_4e41_3156_8a9840fbfa91["initComputed()"]
  e9415a90_94de_e969_0351_990c46050d05 -->|calls| 513e4cf1_6313_4e41_3156_8a9840fbfa91
  style e9415a90_94de_e969_0351_990c46050d05 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

src/core/global-api/extend.ts lines 8–80

export function initExtend(Vue: GlobalAPI) {
  /**
   * Each instance constructor, including Vue, has a unique
   * cid. This enables us to create wrapped "child
   * constructors" for prototypal inheritance and cache them.
   */
  Vue.cid = 0
  let cid = 1

  /**
   * Class inheritance
   */
  Vue.extend = function (extendOptions: any): typeof Component {
    extendOptions = extendOptions || {}
    const Super = this
    const SuperId = Super.cid
    const cachedCtors = extendOptions._Ctor || (extendOptions._Ctor = {})
    if (cachedCtors[SuperId]) {
      return cachedCtors[SuperId]
    }

    const name =
      getComponentName(extendOptions) || getComponentName(Super.options)
    if (__DEV__ && name) {
      validateComponentName(name)
    }

    const Sub = function VueComponent(this: any, options: any) {
      this._init(options)
    } as unknown as typeof Component
    Sub.prototype = Object.create(Super.prototype)
    Sub.prototype.constructor = Sub
    Sub.cid = cid++
    Sub.options = mergeOptions(Super.options, extendOptions)
    Sub['super'] = Super

    // For props and computed properties, we define the proxy getters on
    // the Vue instances at extension time, on the extended prototype. This
    // avoids Object.defineProperty calls for each instance created.
    if (Sub.options.props) {
      initProps(Sub)
    }
    if (Sub.options.computed) {
      initComputed(Sub)
    }

    // allow further extension/mixin/plugin usage
    Sub.extend = Super.extend
    Sub.mixin = Super.mixin
    Sub.use = Super.use

    // create asset registers, so extended classes
    // can have their private assets too.
    ASSET_TYPES.forEach(function (type) {
      Sub[type] = Super[type]
    })
    // enable recursive self-lookup
    if (name) {
      Sub.options.components[name] = Sub
    }

    // keep a reference to the super options at extension time.
    // later at instantiation we can check if Super's options have
    // been updated.
    Sub.superOptions = Super.options
    Sub.extendOptions = extendOptions
    Sub.sealedOptions = extend({}, Sub.options)

    // cache constructor
    cachedCtors[SuperId] = Sub
    return Sub
  }
}

Domain

Subdomains

Called By

Frequently Asked Questions

What does initExtend() do?
initExtend() is a function in the vue codebase.
What does initExtend() call?
initExtend() calls 3 function(s): getComponentName, initComputed, initProps.
What calls initExtend()?
initExtend() is called by 1 function(s): initGlobalAPI.

Analyze Your Own Codebase

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

Try Supermodel Free