-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Handle of private fields in the structured cloning #7123
Comments
I would assume that you'd want to ignore any [[PrivateElements]] slot that's empty. Since objects in the spec don't get slots dynamically added, i guess we would indeed need an AO if you wanted 262 to own the logic - but i'm not sure that's ideal given that HTML can add its own slots, as can 402. |
Hopefully neither HTML nor 402 would add a slot to all objects without changing 262? As for the logic we need, I'm not sure, but we shouldn't reveal whether or not an object has private elements, I'd think. |
I completely agree that should not be revealed. Doesn't that mean though that an object's private elements should be ignored, since literally any object (i think? maybe only those with a mutable [[Prototype]]) could have private fields installed on it with the super return override trick, not just instances of classes with private fields defined? |
Yeah, that would mean adding |
Gotcha. I’ll defer to the editors to decide that, but it seems both very rare, and also, like the behavior of such a ubiquitous slot would need to be considered case-by-case in structured cloning anyways, so I’m not sure there’s an advantage to 262 maintaining a list (of course, if someone were to drive structured cloning as a language proposal directly, that might obviate the concern ;-) ) |
V8 compiles private fields internally to special symbol keys on objects, and the implementation of structured cloning ignores all non-String-keyed own properties. IOW private fields are ignored.
It slipped the last meeting, but I'm bringing up the topic of moving structured clone maintenance over to ecma262 at the next meeting. So my answer here is let the ecma262 editors worry about it. :) |
Ref: tc39/ecma262#1668
In current spec, all objects have an internal slot named
[[PrivateElements]]
. It is not allowed in the structured cloning.Additional: Perhaps a
DataCloneError
should be thrown for objects with private properties or accessors, but that is a breaking change.The text was updated successfully, but these errors were encountered: