Skip to content

Commit 34b7403

Browse files
committed
[build] 6.3.0
1 parent de5cd9b commit 34b7403

File tree

3 files changed

+302
-223
lines changed

3 files changed

+302
-223
lines changed

dist/vue-class-component.common.js

+59-19
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* vue-class-component v6.2.0
2+
* vue-class-component v6.3.0
33
* (c) 2015-present Evan You
44
* @license MIT
55
*/
@@ -11,7 +11,37 @@ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'defau
1111

1212
var Vue = _interopDefault(require('vue'));
1313

14-
var hasProto = { __proto__: [] } instanceof Array;
14+
function reflectionIsSupported() {
15+
return (Reflect && Reflect.defineMetadata) !== undefined;
16+
}
17+
function copyReflectionMetadata(to, from) {
18+
forwardMetadata(to, from);
19+
Object.getOwnPropertyNames(from.prototype).forEach(function (key) {
20+
forwardMetadata(to.prototype, from.prototype, key);
21+
});
22+
Object.getOwnPropertyNames(from).forEach(function (key) {
23+
forwardMetadata(to, from, key);
24+
});
25+
}
26+
function forwardMetadata(to, from, propertyKey) {
27+
var metaKeys = propertyKey
28+
? Reflect.getOwnMetadataKeys(from, propertyKey)
29+
: Reflect.getOwnMetadataKeys(from);
30+
metaKeys.forEach(function (metaKey) {
31+
var metadata = propertyKey
32+
? Reflect.getOwnMetadata(metaKey, from, propertyKey)
33+
: Reflect.getOwnMetadata(metaKey, from);
34+
if (propertyKey) {
35+
Reflect.defineMetadata(metaKey, metadata, to, propertyKey);
36+
}
37+
else {
38+
Reflect.defineMetadata(metaKey, metadata, to);
39+
}
40+
});
41+
}
42+
43+
var fakeArray = { __proto__: [] };
44+
var hasProto = fakeArray instanceof Array;
1545
function createDecorator(factory) {
1646
return function (target, key, index) {
1747
var Ctor = typeof target === 'function'
@@ -35,7 +65,7 @@ function mixins() {
3565
}
3666
function isPrimitive(value) {
3767
var type = typeof value;
38-
return value == null || (type !== "object" && type !== "function");
68+
return value == null || (type !== 'object' && type !== 'function');
3969
}
4070
function warn(message) {
4171
if (typeof console !== 'undefined') {
@@ -62,7 +92,7 @@ function collectDataFromConstructor(vm, Component) {
6292
if (key.charAt(0) !== '_') {
6393
Object.defineProperty(_this, key, {
6494
get: function () { return vm[key]; },
65-
set: function (value) { return vm[key] = value; },
95+
set: function (value) { vm[key] = value; },
6696
configurable: true
6797
});
6898
}
@@ -118,9 +148,20 @@ function componentFactory(Component, options) {
118148
return;
119149
}
120150
var descriptor = Object.getOwnPropertyDescriptor(proto, key);
121-
if (typeof descriptor.value === 'function') {
151+
if (descriptor.value !== void 0) {
122152
// methods
123-
(options.methods || (options.methods = {}))[key] = descriptor.value;
153+
if (typeof descriptor.value === 'function') {
154+
(options.methods || (options.methods = {}))[key] = descriptor.value;
155+
}
156+
else {
157+
// typescript decorated data
158+
(options.mixins || (options.mixins = [])).push({
159+
data: function () {
160+
var _a;
161+
return _a = {}, _a[key] = descriptor.value, _a;
162+
}
163+
});
164+
}
124165
}
125166
else if (descriptor.get || descriptor.set) {
126167
// computed properties
@@ -148,6 +189,9 @@ function componentFactory(Component, options) {
148189
: Vue;
149190
var Extended = Super.extend(options);
150191
forwardStaticMembers(Extended, Component, Super);
192+
if (reflectionIsSupported()) {
193+
copyReflectionMetadata(Extended, Component);
194+
}
151195
return Extended;
152196
}
153197
var reservedPropertyNames = [
@@ -193,15 +237,15 @@ function forwardStaticMembers(Extended, Original, Super) {
193237
return;
194238
}
195239
var superDescriptor = Object.getOwnPropertyDescriptor(Super, key);
196-
if (!isPrimitive(descriptor.value)
197-
&& superDescriptor
198-
&& superDescriptor.value === descriptor.value) {
240+
if (!isPrimitive(descriptor.value) &&
241+
superDescriptor &&
242+
superDescriptor.value === descriptor.value) {
199243
return;
200244
}
201245
}
202246
// Warn if the users manually declare reserved properties
203-
if (process.env.NODE_ENV !== 'production'
204-
&& reservedPropertyNames.indexOf(key) >= 0) {
247+
if (process.env.NODE_ENV !== 'production' &&
248+
reservedPropertyNames.indexOf(key) >= 0) {
205249
warn("Static property name '" + key + "' declared on class '" + Original.name + "' " +
206250
'conflicts with reserved property name of Vue internal. ' +
207251
'It may cause unexpected behavior of the component. Consider renaming the property.');
@@ -218,14 +262,10 @@ function Component(options) {
218262
return componentFactory(Component, options);
219263
};
220264
}
221-
(function (Component) {
222-
function registerHooks(keys) {
223-
$internalHooks.push.apply($internalHooks, keys);
224-
}
225-
Component.registerHooks = registerHooks;
226-
})(Component || (Component = {}));
227-
var Component$1 = Component;
265+
Component.registerHooks = function registerHooks(keys) {
266+
$internalHooks.push.apply($internalHooks, keys);
267+
};
228268

229-
exports.default = Component$1;
269+
exports.default = Component;
230270
exports.createDecorator = createDecorator;
231271
exports.mixins = mixins;

0 commit comments

Comments
 (0)