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

Function initExtend

static/vuejs/vue.esm.js:3887–3967  ·  view source on GitHub ↗
(Vue)

Source from the content-addressed store, hash-verified

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