Skip to content

Commit

Permalink
[changed] doesn't throw when context is missing.
Browse files Browse the repository at this point in the history
  • Loading branch information
jquense committed Apr 5, 2016
1 parent 594fa53 commit 9d70a7b
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions src/util/reference.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,13 @@ export default class Ref {
this.prefix = prefix;
this.isContext = key.indexOf(prefix) === 0
this.path = this.isContext ? this.key.slice(this.prefix.length) : this.key
this._get = getter(this.path)
this._get = getter(this.path, true)
this.map = mapFn || (value => value);
}

getValue(parent, context) {
let isContext = this.isContext

if ((isContext && !context) || (!isContext && !context && !parent))
throw new Error('missing the context necessary to cast this value')

let value = this._get(isContext ? context : (parent || context))

let value = this._get(isContext ? context : (parent || context) || {})
return this.map(value)
}
}
Expand Down

0 comments on commit 9d70a7b

Please sign in to comment.