Skip to content

Commit

Permalink
Merge pull request #198 from dr0p/bugfix/issue-191-cannot-read-enumer…
Browse files Browse the repository at this point in the history
…able-from-undefined

Bugfix (issue-191): Add a guard for missing property descriptor when inheriting enumerable
  • Loading branch information
mweststrate authored Jun 4, 2019
2 parents d90d045 + 1535f52 commit e002bde
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/create-view-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,11 @@ export class ViewModel<T> implements IViewModel<T> {
this.localComputedValues.set(key, computed(derivation.bind(this)))
}

const { enumerable } = Object.getOwnPropertyDescriptor(model, key)
const descriptor = Object.getOwnPropertyDescriptor(model, key);
const additionalDescriptor = descriptor ? { enumerable: descriptor.enumerable } : {};

Object.defineProperty(this, key, {
enumerable,
...additionalDescriptor,
configurable: true,
get: () => {
if (isComputedProp(model, key)) return this.localComputedValues.get(key).get()
Expand Down

0 comments on commit e002bde

Please sign in to comment.