MCPcopy Create free account
hub / github.com/TruthHun/BookStack / initExtend

Function initExtend

static/vuejs/vue.runtime.common.js:3885–3965  ·  view source on GitHub ↗
(Vue)

Source from the content-addressed store, hash-verified

3883/* */
3884
3885function initExtend (Vue) {
3886 /**
3887 * Each instance constructor, including Vue, has a unique
3888 * cid. This enables us to create wrapped "child
3889 * constructors" for prototypal inheritance and cache them.
3890 */
3891 Vue.cid = 0;
3892 var cid = 1;
3893
3894 /**
3895 * Class inheritance
3896 */
3897 Vue.extend = function (extendOptions) {
3898 extendOptions = extendOptions || {};
3899 var Super = this;
3900 var SuperId = Super.cid;
3901 var cachedCtors = extendOptions._Ctor || (extendOptions._Ctor = {});
3902 if (cachedCtors[SuperId]) {
3903 return cachedCtors[SuperId]
3904 }
3905
3906 var name = extendOptions.name || Super.options.name;
3907 if (process.env.NODE_ENV !== 'production') {
3908 if (!/^[a-zA-Z][\w-]*$/.test(name)) {
3909 warn(
3910 'Invalid component name: "' + name + '". Component names ' +
3911 'can only contain alphanumeric characters and the hyphen, ' +
3912 'and must start with a letter.'
3913 );
3914 }
3915 }
3916
3917 var Sub = function VueComponent (options) {
3918 this._init(options);
3919 };
3920 Sub.prototype = Object.create(Super.prototype);
3921 Sub.prototype.constructor = Sub;
3922 Sub.cid = cid++;
3923 Sub.options = mergeOptions(
3924 Super.options,
3925 extendOptions
3926 );
3927 Sub['super'] = Super;
3928
3929 // For props and computed properties, we define the proxy getters on
3930 // the Vue instances at extension time, on the extended prototype. This
3931 // avoids Object.defineProperty calls for each instance created.
3932 if (Sub.options.props) {
3933 initProps$1(Sub);
3934 }
3935 if (Sub.options.computed) {
3936 initComputed$1(Sub);
3937 }
3938
3939 // allow further extension/mixin/plugin usage
3940 Sub.extend = Super.extend;
3941 Sub.mixin = Super.mixin;
3942 Sub.use = Super.use;

Callers 1

initGlobalAPIFunction · 0.70

Calls 5

mergeOptionsFunction · 0.70
initProps$1Function · 0.70
initComputed$1Function · 0.70
extendFunction · 0.70
warnFunction · 0.50

Tested by

no test coverage detected