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

Function initExtend

static/vuejs/vue.runtime.js:3879–3959  ·  view source on GitHub ↗
(Vue)

Source from the content-addressed store, hash-verified

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