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; |
} |