Skip to content

Commit

Permalink
use new Path api (see #267)
Browse files Browse the repository at this point in the history
  • Loading branch information
Scott J. Miles committed Sep 4, 2013
1 parent 2f7c655 commit cc63fcb
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/instance/properties.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,16 @@
// bind a property in A to a path in B by converting A[property] to a
// getter/setter pair that accesses B[...path...]
function bindProperties(inA, inProperty, inB, inPath) {
log.bind && console.log(LOG_BIND_PROPS, inB.localName || 'object', inPath, inA.localName, inProperty);
log.bind && console.log(LOG_BIND_PROPS, inB.localName || 'object',
inPath, inA.localName, inProperty);
// capture A's value if B's value is null or undefined,
// otherwise use B's value
var v = PathObserver.getValueAtPath(inB, inPath);
var path = Path.get(inPath);
var v = path.getValueFrom(inB);
if (v === null || v === undefined) {
PathObserver.setValueAtPath(inB, inPath, inA[inProperty]);
path.setValueFrom(inB, inA[inProperty]);
}
return PathObserver.defineProperty(inA, inProperty,
return PathObserver.defineProperty(inA, inProperty,
{object: inB, path: inPath});
}

Expand Down

0 comments on commit cc63fcb

Please sign in to comment.