Skip to content
This repository has been archived by the owner on Mar 13, 2018. It is now read-only.

Commit

Permalink
Make third argument to PathObserver callback path
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelw committed May 29, 2014
1 parent d99eff1 commit 4905f0b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/observe.js
Original file line number Diff line number Diff line change
Expand Up @@ -1030,7 +1030,7 @@
if (skipChanges || areSameValue(this.value_, oldValue))
return false;

this.report_([this.value_, oldValue]);
this.report_([this.value_, oldValue, this.path_]);
return true;
},

Expand Down
22 changes: 22 additions & 0 deletions tests/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,28 @@ suite('PathObserver Tests', function() {

teardown(doTeardown);

test('Callback args', function() {
var obj = {
foo: 'bar'
};

var path = Path.get('foo');
var observer = new PathObserver(obj, path);

var args;
observer.open(function() {
args = Array.prototype.slice.apply(arguments);
});

obj.foo = 'baz';
observer.deliver();
assert.strictEqual(args.length, 3);
assert.strictEqual(args[0], 'baz');
assert.strictEqual(args[1], 'bar');
assert.strictEqual(args[2], path);
observer.close();
});

test('invalid', function() {
var observer = new PathObserver({ a: { b: 1 }} , 'a b');
observer.open(callback);
Expand Down

0 comments on commit 4905f0b

Please sign in to comment.