Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(409)

Unified Diff: src/object-observe.js

Issue 11419078: Object.observe/unobserve now return object (Closed) Base URL: git://github.com/v8/v8.git@master
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | test/mjsunit/harmony/object-observe.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/object-observe.js
diff --git a/src/object-observe.js b/src/object-observe.js
index ea5de1f6e5b2b5e538a95890e392cbcbd10ac2a7..c9ae652a53e1d273871bbdb510ce5d31bd89fa3d 100644
--- a/src/object-observe.js
+++ b/src/object-observe.js
@@ -88,10 +88,10 @@ function ObjectObserve(object, callback) {
}
var changeObservers = objectInfo.changeObservers;
- if (changeObservers.indexOf(callback) >= 0)
- return;
+ if (changeObservers.indexOf(callback) < 0)
+ changeObservers.push(callback);
- changeObservers.push(callback);
+ return object;
}
function ObjectUnobserve(object, callback) {
@@ -102,14 +102,14 @@ function ObjectUnobserve(object, callback) {
var objectInfo = objectInfoMap.get(object);
if (IS_UNDEFINED(objectInfo))
- return;
+ return object;
var changeObservers = objectInfo.changeObservers;
var index = changeObservers.indexOf(callback);
- if (index < 0)
- return;
+ if (index >= 0)
+ changeObservers.splice(index, 1);
- changeObservers.splice(index, 1);
+ return object;
}
function EnqueueChangeRecord(changeRecord, observers) {
« no previous file with comments | « no previous file | test/mjsunit/harmony/object-observe.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698