Skip to content

Commit d532839

Browse files
authored
Merge pull request #3 from davestewart/fix/0002-global-state
Revert to previous prototype walk algorithm
2 parents 3857869 + b2bf8db commit d532839

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "vue-class-store",
33
"description": "Universal Vue stores you write once and use anywhere",
4-
"version": "2.0.3",
4+
"version": "2.0.4",
55
"author": "Dave Stewart",
66
"license": "MIT",
77
"main": "dist/vue-class-store.js",

src/index.ts

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
1-
import Vue, { ComponentOptions, VueConstructor } from 'vue'
1+
import Vue, { ComponentOptions } from 'vue'
22

33
type C = { new (...args: any[]): {} }
44

55
type R = Record<any, any>
66

7-
function getDescriptors (model: R) {
7+
export function makeOptions(model: R): ComponentOptions<any> {
8+
// prototype
89
const prototype = Object.getPrototypeOf(model)
9-
if (prototype === null || prototype === Object.prototype) {
10+
if (!prototype || prototype === Object.prototype) {
1011
return {}
1112
}
12-
const prototypeDescriptors = getDescriptors(prototype)
13-
const descriptors = Object.getOwnPropertyDescriptors(prototype)
14-
return { ...prototypeDescriptors, ...descriptors }
15-
}
1613

17-
export function makeOptions(model: R): ComponentOptions<any> {
18-
// prototype
19-
const prototype = Object.getPrototypeOf(model)
20-
const descriptors = getDescriptors(prototype)
14+
// parent options
15+
const extendsOptions = makeOptions(prototype)
16+
17+
// descriptors
18+
const descriptors = Object.getOwnPropertyDescriptors(prototype)
2119

2220
// options
2321
const name = prototype.constructor.name
@@ -59,6 +57,7 @@ export function makeOptions(model: R): ComponentOptions<any> {
5957
// return
6058
return {
6159
name,
60+
extends: extendsOptions,
6261
computed,
6362
methods,
6463
watch,

0 commit comments

Comments
 (0)