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

Function initExtend

static/vuejs/vue.common.js:3889–3969  ·  view source on GitHub ↗
(Vue)

Source from the content-addressed store, hash-verified

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