From 16f8b7c97039b89b7ba233c721163e157ae571fb Mon Sep 17 00:00:00 2001 From: Rafael Weinstein Date: Tue, 1 Oct 2013 17:27:44 -0700 Subject: [PATCH] Include observed array as forth callback arg for non-valueFn CompoundPathObserver. The array is a set of tuples: [object, path, object, path, ....]; R=arv BUG= Review URL: https://codereview.appspot.com/14251043 --- src/observe.js | 3 ++- tests/test.js | 16 ++++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/observe.js b/src/observe.js index bf80f8c..192f767 100644 --- a/src/observe.js +++ b/src/observe.js @@ -781,7 +781,8 @@ this.reportArgs = [this.value, this.oldValue]; } else { - this.reportArgs = [this.values, this.oldValues, this.changeFlags]; + this.reportArgs = [this.values, this.oldValues, this.changeFlags, + this.observed]; } return true; diff --git a/tests/test.js b/tests/test.js index 276fc4a..43afbeb 100644 --- a/tests/test.js +++ b/tests/test.js @@ -54,7 +54,7 @@ function assertPathChanges(expectNewValue, expectOldValue) { } function assertCompoundPathChanges(expectNewValues, expectOldValues, - expectChangeFlags) { + expectChangeFlags, expectObserverArg) { observer.deliver(); assert.isTrue(callbackInvoked); @@ -62,9 +62,11 @@ function assertCompoundPathChanges(expectNewValues, expectOldValues, var newValues = callbackArgs[0]; var oldValues = callbackArgs[1]; var changeFlags = callbackArgs[2]; + var observerArg = callbackArgs[3]; assert.deepEqual(expectNewValues, newValues); assert.deepEqual(expectOldValues, oldValues); assert.deepEqual(expectChangeFlags, changeFlags); + assert.deepEqual(expectObserverArg, observerArg); assert.isTrue(window.dirtyCheckCycleCount === undefined || window.dirtyCheckCycleCount === 1); @@ -850,19 +852,25 @@ suite('CompoundPathObserver Tests', function() { observer.addPath(model, Path.get('c')); observer.start(); + var observerCallbackArg = [model, Path.get('a'), + model, Path.get('b'), + model, Path.get('c')]; model.a = -10; model.b = 20; model.c = 30; - assertCompoundPathChanges([-10, 20, 30], [1, 2, 3], [true, true, true]); + assertCompoundPathChanges([-10, 20, 30], [1, 2, 3], + [true, true, true], + observerCallbackArg); model.a = 'a'; model.c = 'c'; - assertCompoundPathChanges(['a', 20, 'c'], [-10, 20, 30], [true, false, true]); + assertCompoundPathChanges(['a', 20, 'c'], [-10, 20, 30], + [true, false, true], + observerCallbackArg); observer.close(); }); - test('Simple - valueFn', function() { var model = { a: 1, b: 2, c: 3 };