-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clarify in which Realm records, record arrays, and associated objects are created #3
Comments
What should happen in the following scenario? // realm-a
var object = ...
function callbackA(records) {}
Object.observe(object, callbackA);
// realm-b
var object = realmA.object;
function callbackB(records) {}
Object.observe(obj, callbackB);
// realm-c
realmA.object.x = 42; Does |
One possible solution is that |
What about two different observers in the same realm? I think you'd want them to share records if possible (to avoid unnecessary record allocations). |
Yes. Same. I was thinking we would get the [[Realm]] of the callback function and use that to determine which realm to create the array and records for. |
@domenic suggested using the [[Realm]] of the |
There can be multiple |
Yeah. It is not obvious. I'm going to create a branch and see how it works out. |
My thinking (which was pretty cursory) is that when someone does Object.observe(objFromOtherRealm, function (records) {
}); they expect the records to have assert(Object.getPrototypeOf(records[0]) === Object.prototype) |
Or? assert(Object.getPrototypeOf(records[0]) === callbackFunction.__proto__.__proto_) the |
Another issue is. windowA.Object.getNotifier(obj) === windowB.Object.getNotifier(obj); // ? I think this must be false due to ocap. |
Between the realm of the So given that, I would say between those two choose whichever makes the spec and implementation easier. |
The current spec is silent on this, which will cause records to be created in the Realm of the function where object mutation occurs, record arrays to be created who-knows-where (maybe in the Realm of the first mutation per observer?).
The V8 implementation diverges from this by using the Realm V8 internally associates with the observed object for all such creations.
The text was updated successfully, but these errors were encountered: