initExtend() — vue Function Reference
Architecture documentation for the initExtend() function in extend.ts from the vue codebase.
Entity Profile
Dependency Diagram
graph TD 9a536aa5_012c_cfe5_4928_935535d711d7["initExtend()"] 295edfdd_f910_fae9_5ece_4985c36859c4["extend.ts"] 9a536aa5_012c_cfe5_4928_935535d711d7 -->|defined in| 295edfdd_f910_fae9_5ece_4985c36859c4 157a933a_63b7_ebeb_71f9_e11bccd3097b["initGlobalAPI()"] 157a933a_63b7_ebeb_71f9_e11bccd3097b -->|calls| 9a536aa5_012c_cfe5_4928_935535d711d7 07237020_2f32_55be_02ad_e77197985632["getComponentName()"] 9a536aa5_012c_cfe5_4928_935535d711d7 -->|calls| 07237020_2f32_55be_02ad_e77197985632 633e435b_6794_5170_c66c_026a552fcc59["initProps()"] 9a536aa5_012c_cfe5_4928_935535d711d7 -->|calls| 633e435b_6794_5170_c66c_026a552fcc59 3430fea3_ff5d_f4b7_a4ca_f1257a327ab1["initComputed()"] 9a536aa5_012c_cfe5_4928_935535d711d7 -->|calls| 3430fea3_ff5d_f4b7_a4ca_f1257a327ab1 style 9a536aa5_012c_cfe5_4928_935535d711d7 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
Defined In
Called By
Source
Frequently Asked Questions
What does initExtend() do?
initExtend() is a function in the vue codebase, defined in src/core/global-api/extend.ts.
Where is initExtend() defined?
initExtend() is defined in src/core/global-api/extend.ts at line 8.
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