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

Unified Diff: src/object-observe.js

Issue 11554019: Object.observe: Make array length and other magic data properties work correctly. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressing Michael's comments Created 8 years 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 | src/objects.cc » ('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 8c2895f4bdeaf7f14076feae20f4c6b790f96868..3ed27716837d9980a818f6c8d30cd665692eb78b 100644
--- a/src/object-observe.js
+++ b/src/object-observe.js
@@ -84,8 +84,8 @@ function ObjectObserve(object, callback) {
var objectInfo = objectInfoMap.get(object);
if (IS_UNDEFINED(objectInfo)) {
objectInfo = CreateObjectInfo(object);
- %SetIsObserved(object, true);
}
+ %SetIsObserved(object, true);
var changeObservers = objectInfo.changeObservers;
if (changeObservers.indexOf(callback) < 0)
@@ -106,8 +106,11 @@ function ObjectUnobserve(object, callback) {
var changeObservers = objectInfo.changeObservers;
var index = changeObservers.indexOf(callback);
- if (index >= 0)
+ if (index >= 0) {
changeObservers.splice(index, 1);
+ if (changeObservers.length === 0)
+ %SetIsObserved(object, false);
+ }
return object;
}
« no previous file with comments | « no previous file | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698