From 73f4e4c1d9cc3b5fad9f3ec1ffcd5fb779bb6f1c Mon Sep 17 00:00:00 2001 From: fmdm Date: Thu, 14 Sep 2017 08:56:43 +0300 Subject: [PATCH 1/5] +statics --- src/component.ts | 9 +++++++-- test/test.ts | 10 ++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/component.ts b/src/component.ts index 4386e24..0547509 100644 --- a/src/component.ts +++ b/src/component.ts @@ -57,12 +57,17 @@ export function componentFactory ( const decorators = (Component as DecoratedClass).__decorators__ if (decorators) { decorators.forEach(fn => fn(options)) - } + } // find super const superProto = Object.getPrototypeOf(Component.prototype) const Super = superProto instanceof Vue ? superProto.constructor as VueClass : Vue - return Super.extend(options) + const rv = Super.extend(options); + + for(let sttc in Component) + if(!(sttc in function() {}) && Component.hasOwnProperty(sttc)) + rv[sttc] = Component[sttc]; + return rv; } diff --git a/test/test.ts b/test/test.ts index 0970ac0..8b58ccb 100644 --- a/test/test.ts +++ b/test/test.ts @@ -256,4 +256,14 @@ describe('vue-class-component', () => { expect(parent.value).to.equal('parent') expect(child.value).to.equal('child') }) + + it('forwardStatics', function () { + debugger; + @Component + class MyComp extends Vue { + static myValue = 52 + } + + expect(MyComp.myValue).to.equal(52); + }) }) From e4d22fded79712685356d35c6a80eacdd6171f17 Mon Sep 17 00:00:00 2001 From: fmdm Date: Thu, 14 Sep 2017 09:00:00 +0300 Subject: [PATCH 2/5] identation correction --- src/component.ts | 12 ++++++------ test/test.ts | 18 +++++++++--------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/component.ts b/src/component.ts index 0547509..d598aa8 100644 --- a/src/component.ts +++ b/src/component.ts @@ -57,7 +57,7 @@ export function componentFactory ( const decorators = (Component as DecoratedClass).__decorators__ if (decorators) { decorators.forEach(fn => fn(options)) - } + } // find super const superProto = Object.getPrototypeOf(Component.prototype) @@ -65,9 +65,9 @@ export function componentFactory ( ? superProto.constructor as VueClass : Vue const rv = Super.extend(options); - - for(let sttc in Component) - if(!(sttc in function() {}) && Component.hasOwnProperty(sttc)) - rv[sttc] = Component[sttc]; - return rv; + + for(let sttc in Component) + if(!(sttc in function() {}) && Component.hasOwnProperty(sttc)) + rv[sttc] = Component[sttc]; + return rv; } diff --git a/test/test.ts b/test/test.ts index 8b58ccb..a8b9fe7 100644 --- a/test/test.ts +++ b/test/test.ts @@ -257,13 +257,13 @@ describe('vue-class-component', () => { expect(child.value).to.equal('child') }) - it('forwardStatics', function () { - debugger; - @Component - class MyComp extends Vue { - static myValue = 52 - } - - expect(MyComp.myValue).to.equal(52); - }) + it('forwardStatics', function () { + debugger; + @Component + class MyComp extends Vue { + static myValue = 52 + } + + expect(MyComp.myValue).to.equal(52); + }) }) From b23216b7d9611e766df790a82b50fafc29ca1738 Mon Sep 17 00:00:00 2001 From: fmdm Date: Thu, 14 Sep 2017 11:57:18 +0300 Subject: [PATCH 3/5] -debugger --- test/test.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/test/test.ts b/test/test.ts index a8b9fe7..193d961 100644 --- a/test/test.ts +++ b/test/test.ts @@ -258,7 +258,6 @@ describe('vue-class-component', () => { }) it('forwardStatics', function () { - debugger; @Component class MyComp extends Vue { static myValue = 52 From a242026471aab29cec6d23d050ebe12c73fed382 Mon Sep 17 00:00:00 2001 From: fmdm Date: Fri, 15 Sep 2017 09:40:45 +0300 Subject: [PATCH 4/5] presentation --- src/component.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/component.ts b/src/component.ts index d598aa8..cc021ee 100644 --- a/src/component.ts +++ b/src/component.ts @@ -64,10 +64,12 @@ export function componentFactory ( const Super = superProto instanceof Vue ? superProto.constructor as VueClass : Vue - const rv = Super.extend(options); + const Extended = Super.extend(options); - for(let sttc in Component) - if(!(sttc in function() {}) && Component.hasOwnProperty(sttc)) - rv[sttc] = Component[sttc]; - return rv; + for(let staticKey in Component) { + if(!(staticKey in function() {}) && Component.hasOwnProperty(staticKey)) { + Extended[staticKey] = Component[staticKey]; + } + } + return Extended; } From e192193ea08ae1870a7e4e3f6dbec98a6ef3f132 Mon Sep 17 00:00:00 2001 From: fmdm Date: Sat, 16 Sep 2017 17:02:32 +0300 Subject: [PATCH 5/5] - function defaults --- src/component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/component.ts b/src/component.ts index cc021ee..c3f1e5c 100644 --- a/src/component.ts +++ b/src/component.ts @@ -67,7 +67,7 @@ export function componentFactory ( const Extended = Super.extend(options); for(let staticKey in Component) { - if(!(staticKey in function() {}) && Component.hasOwnProperty(staticKey)) { + if(Component.hasOwnProperty(staticKey)) { Extended[staticKey] = Component[staticKey]; } }