Skip to content

Commit c855233

Browse files
committed
avoid init super class while building component
1 parent 451e68f commit c855233

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ function Component(options) {
2323
}
2424
options.name = options.name || Component.name;
2525
var proto = Component.prototype;
26+
if (Object.getPrototypeOf(proto) instanceof Vue) Object.setPrototypeOf(proto.constructor, function () {});
2627
var constructor = new proto.constructor();
2728
var vueKeys = [];
2829
if (proto.vuex) {

src/component.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ export function Component(options? : ComponentOptions<Vue>): ClassDecorator {
3737

3838
// class prototype.
3939
var proto = Component.prototype
40+
41+
// avoid parent component initialization while building component
42+
if (Object.getPrototypeOf(proto) instanceof Vue)
43+
Object.setPrototypeOf(proto.constructor, function() {})
44+
4045
var constructor = new proto.constructor();
4146

4247

test/common/specs/basic.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,10 @@ describe('vue-class-component based test (ts)', () => {
200200
b: number
201201

202202
constructor() {
203-
super();
203+
super();
204+
}
205+
206+
created() {
204207
this.b = this.a + 1
205208
}
206209
}

0 commit comments

Comments
 (0)