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

Unified Diff: src/object-observe.js

Issue 11347037: Object.observe: generate change records for named properties. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 2 months 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 | « src/ic.cc ('k') | src/objects.h » ('j') | src/objects.h » ('J')
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 dcf98d84aed1e66359b2c71d8f648733f7479922..9f01acf829fe2ecc89bb8fa2885c9735cd625d67 100644
--- a/src/object-observe.js
+++ b/src/object-observe.js
@@ -68,6 +68,7 @@ function ObjectObserve(object, callback) {
changeObservers: new InternalArray(callback)
};
objectInfoMap.set(object, objectInfo);
+ %SetIsObserved(object, true);
return;
}
rafaelw 2012/10/31 14:44:31 do we have JS debug-only ASSERTS? If so, it'd be n
rossberg 2012/11/05 17:11:08 Unfortunately, no.
@@ -109,6 +110,16 @@ function EnqueueChangeRecord(changeRecord, observers) {
}
}
+function NotifyChange(type, object, name, oldValue) {
+ var objectInfo = objectInfoMap.get(object);
+ if (IS_UNDEFINED(objectInfo)) return;
rafaelw 2012/10/31 14:44:31 Seems like we should CHECK() here - can we crash f
rossberg 2012/11/05 17:11:08 There is no direct way to do that, but I just remo
+
+ var changeRecord = { type: type, object: object, name: name };
+ if (arguments.length == 4) changeRecord.oldValue = oldValue;
rafaelw 2012/10/31 14:44:31 For safety, I think that you should switch on argu
rossberg 2012/11/05 17:11:08 Done.
+ InternalObjectFreeze(changeRecord);
+ EnqueueChangeRecord(changeRecord, objectInfo.changeObservers);
+}
+
function ObjectNotify(object, changeRecord) {
// TODO: notifier needs to be [[THIS]]
if (!IS_STRING(changeRecord.type))
@@ -119,7 +130,7 @@ function ObjectNotify(object, changeRecord) {
return;
var newRecord = {
- object: object // TODO: Needs to be 'object' retreived from notifier
+ object: object // TODO: Needs to be 'object' retrieved from notifier
};
for (var prop in changeRecord) {
if (prop === 'object')
@@ -161,4 +172,4 @@ function SetupObjectObserve() {
));
}
-SetupObjectObserve();
+SetupObjectObserve();
« no previous file with comments | « src/ic.cc ('k') | src/objects.h » ('j') | src/objects.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698