Skip to content

Commit 7213dbe

Browse files
committed
[build] 6.2.0
1 parent cdcbfe5 commit 7213dbe

File tree

3 files changed

+87
-11
lines changed

3 files changed

+87
-11
lines changed

dist/vue-class-component.common.js

+42-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
2-
* vue-class-component v6.1.2
3-
* (c) 2015-2017 Evan You
2+
* vue-class-component v6.2.0
3+
* (c) 2015-present Evan You
44
* @license MIT
55
*/
66
'use strict';
@@ -26,6 +26,13 @@ function createDecorator(factory) {
2626
Ctor.__decorators__.push(function (options) { return factory(options, key, index); });
2727
};
2828
}
29+
function mixins() {
30+
var Ctors = [];
31+
for (var _i = 0; _i < arguments.length; _i++) {
32+
Ctors[_i] = arguments[_i];
33+
}
34+
return Vue.extend({ mixins: Ctors });
35+
}
2936
function isPrimitive(value) {
3037
var type = typeof value;
3138
return value == null || (type !== "object" && type !== "function");
@@ -37,10 +44,13 @@ function warn(message) {
3744
}
3845

3946
function collectDataFromConstructor(vm, Component) {
47+
// override _init to prevent to init as Vue instance
4048
var originalInit = Component.prototype._init;
4149
Component.prototype._init = function () {
4250
var _this = this;
51+
// proxy to actual vm
4352
var keys = Object.getOwnPropertyNames(vm);
53+
// 2.2.0 compat (props are no longer exposed as self properties)
4454
if (vm.$options.props) {
4555
for (var key in vm.$options.props) {
4656
if (!vm.hasOwnProperty(key)) {
@@ -58,8 +68,11 @@ function collectDataFromConstructor(vm, Component) {
5868
}
5969
});
6070
};
71+
// should be acquired class property values
6172
var data = new Component();
73+
// restore original _init to avoid memory leak (#209)
6274
Component.prototype._init = originalInit;
75+
// create plain data object
6376
var plainData = {};
6477
Object.keys(data).forEach(function (key) {
6578
if (data[key] !== undefined) {
@@ -88,25 +101,29 @@ var $internalHooks = [
88101
'activated',
89102
'deactivated',
90103
'render',
91-
'errorCaptured'
104+
'errorCaptured' // 2.5
92105
];
93106
function componentFactory(Component, options) {
94107
if (options === void 0) { options = {}; }
95108
options.name = options.name || Component._componentTag || Component.name;
109+
// prototype props.
96110
var proto = Component.prototype;
97111
Object.getOwnPropertyNames(proto).forEach(function (key) {
98112
if (key === 'constructor') {
99113
return;
100114
}
115+
// hooks
101116
if ($internalHooks.indexOf(key) > -1) {
102117
options[key] = proto[key];
103118
return;
104119
}
105120
var descriptor = Object.getOwnPropertyDescriptor(proto, key);
106121
if (typeof descriptor.value === 'function') {
122+
// methods
107123
(options.methods || (options.methods = {}))[key] = descriptor.value;
108124
}
109125
else if (descriptor.get || descriptor.set) {
126+
// computed properties
110127
(options.computed || (options.computed = {}))[key] = {
111128
get: descriptor.get,
112129
set: descriptor.set
@@ -118,11 +135,13 @@ function componentFactory(Component, options) {
118135
return collectDataFromConstructor(this, Component);
119136
}
120137
});
138+
// decorate options
121139
var decorators = Component.__decorators__;
122140
if (decorators) {
123141
decorators.forEach(function (fn) { return fn(options); });
124142
delete Component.__decorators__;
125143
}
144+
// find super
126145
var superProto = Object.getPrototypeOf(Component.prototype);
127146
var Super = superProto instanceof Vue
128147
? superProto.constructor
@@ -132,27 +151,44 @@ function componentFactory(Component, options) {
132151
return Extended;
133152
}
134153
var reservedPropertyNames = [
154+
// Unique id
135155
'cid',
156+
// Super Vue constructor
136157
'super',
158+
// Component options that will be used by the component
137159
'options',
138160
'superOptions',
139161
'extendOptions',
140162
'sealedOptions',
163+
// Private assets
141164
'component',
142165
'directive',
143166
'filter'
144167
];
145168
function forwardStaticMembers(Extended, Original, Super) {
169+
// We have to use getOwnPropertyNames since Babel registers methods as non-enumerable
146170
Object.getOwnPropertyNames(Original).forEach(function (key) {
171+
// `prototype` should not be overwritten
147172
if (key === 'prototype') {
148173
return;
149174
}
175+
// Some browsers does not allow reconfigure built-in properties
150176
var extendedDescriptor = Object.getOwnPropertyDescriptor(Extended, key);
151177
if (extendedDescriptor && !extendedDescriptor.configurable) {
152178
return;
153179
}
154180
var descriptor = Object.getOwnPropertyDescriptor(Original, key);
181+
// If the user agent does not support `__proto__` or its family (IE <= 10),
182+
// the sub class properties may be inherited properties from the super class in TypeScript.
183+
// We need to exclude such properties to prevent to overwrite
184+
// the component options object which stored on the extended constructor (See #192).
185+
// If the value is a referenced value (object or function),
186+
// we can check equality of them and exclude it if they have the same reference.
187+
// If it is a primitive value, it will be forwarded for safety.
155188
if (!hasProto) {
189+
// Only `cid` is explicitly exluded from property forwarding
190+
// because we cannot detect whether it is a inherited property or not
191+
// on the no `__proto__` environment even though the property is reserved.
156192
if (key === 'cid') {
157193
return;
158194
}
@@ -163,6 +199,7 @@ function forwardStaticMembers(Extended, Original, Super) {
163199
return;
164200
}
165201
}
202+
// Warn if the users manually declare reserved properties
166203
if (process.env.NODE_ENV !== 'production'
167204
&& reservedPropertyNames.indexOf(key) >= 0) {
168205
warn("Static property name '" + key + "' declared on class '" + Original.name + "' " +
@@ -189,5 +226,6 @@ function Component(options) {
189226
})(Component || (Component = {}));
190227
var Component$1 = Component;
191228

192-
exports['default'] = Component$1;
229+
exports.default = Component$1;
193230
exports.createDecorator = createDecorator;
231+
exports.mixins = mixins;

dist/vue-class-component.js

+42-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
2-
* vue-class-component v6.1.2
3-
* (c) 2015-2017 Evan You
2+
* vue-class-component v6.2.0
3+
* (c) 2015-present Evan You
44
* @license MIT
55
*/
66
(function (global, factory) {
@@ -26,6 +26,13 @@ function createDecorator(factory) {
2626
Ctor.__decorators__.push(function (options) { return factory(options, key, index); });
2727
};
2828
}
29+
function mixins() {
30+
var Ctors = [];
31+
for (var _i = 0; _i < arguments.length; _i++) {
32+
Ctors[_i] = arguments[_i];
33+
}
34+
return Vue.extend({ mixins: Ctors });
35+
}
2936
function isPrimitive(value) {
3037
var type = typeof value;
3138
return value == null || (type !== "object" && type !== "function");
@@ -37,10 +44,13 @@ function warn(message) {
3744
}
3845

3946
function collectDataFromConstructor(vm, Component) {
47+
// override _init to prevent to init as Vue instance
4048
var originalInit = Component.prototype._init;
4149
Component.prototype._init = function () {
4250
var _this = this;
51+
// proxy to actual vm
4352
var keys = Object.getOwnPropertyNames(vm);
53+
// 2.2.0 compat (props are no longer exposed as self properties)
4454
if (vm.$options.props) {
4555
for (var key in vm.$options.props) {
4656
if (!vm.hasOwnProperty(key)) {
@@ -58,8 +68,11 @@ function collectDataFromConstructor(vm, Component) {
5868
}
5969
});
6070
};
71+
// should be acquired class property values
6172
var data = new Component();
73+
// restore original _init to avoid memory leak (#209)
6274
Component.prototype._init = originalInit;
75+
// create plain data object
6376
var plainData = {};
6477
Object.keys(data).forEach(function (key) {
6578
if (data[key] !== undefined) {
@@ -88,25 +101,29 @@ var $internalHooks = [
88101
'activated',
89102
'deactivated',
90103
'render',
91-
'errorCaptured'
104+
'errorCaptured' // 2.5
92105
];
93106
function componentFactory(Component, options) {
94107
if (options === void 0) { options = {}; }
95108
options.name = options.name || Component._componentTag || Component.name;
109+
// prototype props.
96110
var proto = Component.prototype;
97111
Object.getOwnPropertyNames(proto).forEach(function (key) {
98112
if (key === 'constructor') {
99113
return;
100114
}
115+
// hooks
101116
if ($internalHooks.indexOf(key) > -1) {
102117
options[key] = proto[key];
103118
return;
104119
}
105120
var descriptor = Object.getOwnPropertyDescriptor(proto, key);
106121
if (typeof descriptor.value === 'function') {
122+
// methods
107123
(options.methods || (options.methods = {}))[key] = descriptor.value;
108124
}
109125
else if (descriptor.get || descriptor.set) {
126+
// computed properties
110127
(options.computed || (options.computed = {}))[key] = {
111128
get: descriptor.get,
112129
set: descriptor.set
@@ -118,11 +135,13 @@ function componentFactory(Component, options) {
118135
return collectDataFromConstructor(this, Component);
119136
}
120137
});
138+
// decorate options
121139
var decorators = Component.__decorators__;
122140
if (decorators) {
123141
decorators.forEach(function (fn) { return fn(options); });
124142
delete Component.__decorators__;
125143
}
144+
// find super
126145
var superProto = Object.getPrototypeOf(Component.prototype);
127146
var Super = superProto instanceof Vue
128147
? superProto.constructor
@@ -132,27 +151,44 @@ function componentFactory(Component, options) {
132151
return Extended;
133152
}
134153
var reservedPropertyNames = [
154+
// Unique id
135155
'cid',
156+
// Super Vue constructor
136157
'super',
158+
// Component options that will be used by the component
137159
'options',
138160
'superOptions',
139161
'extendOptions',
140162
'sealedOptions',
163+
// Private assets
141164
'component',
142165
'directive',
143166
'filter'
144167
];
145168
function forwardStaticMembers(Extended, Original, Super) {
169+
// We have to use getOwnPropertyNames since Babel registers methods as non-enumerable
146170
Object.getOwnPropertyNames(Original).forEach(function (key) {
171+
// `prototype` should not be overwritten
147172
if (key === 'prototype') {
148173
return;
149174
}
175+
// Some browsers does not allow reconfigure built-in properties
150176
var extendedDescriptor = Object.getOwnPropertyDescriptor(Extended, key);
151177
if (extendedDescriptor && !extendedDescriptor.configurable) {
152178
return;
153179
}
154180
var descriptor = Object.getOwnPropertyDescriptor(Original, key);
181+
// If the user agent does not support `__proto__` or its family (IE <= 10),
182+
// the sub class properties may be inherited properties from the super class in TypeScript.
183+
// We need to exclude such properties to prevent to overwrite
184+
// the component options object which stored on the extended constructor (See #192).
185+
// If the value is a referenced value (object or function),
186+
// we can check equality of them and exclude it if they have the same reference.
187+
// If it is a primitive value, it will be forwarded for safety.
155188
if (!hasProto) {
189+
// Only `cid` is explicitly exluded from property forwarding
190+
// because we cannot detect whether it is a inherited property or not
191+
// on the no `__proto__` environment even though the property is reserved.
156192
if (key === 'cid') {
157193
return;
158194
}
@@ -163,6 +199,7 @@ function forwardStaticMembers(Extended, Original, Super) {
163199
return;
164200
}
165201
}
202+
// Warn if the users manually declare reserved properties
166203
if ("development" !== 'production'
167204
&& reservedPropertyNames.indexOf(key) >= 0) {
168205
warn("Static property name '" + key + "' declared on class '" + Original.name + "' " +
@@ -189,8 +226,9 @@ function Component(options) {
189226
})(Component || (Component = {}));
190227
var Component$1 = Component;
191228

192-
exports['default'] = Component$1;
229+
exports.default = Component$1;
193230
exports.createDecorator = createDecorator;
231+
exports.mixins = mixins;
194232

195233
Object.defineProperty(exports, '__esModule', { value: true });
196234

dist/vue-class-component.min.js

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)