You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am not opposed to an accessor own property but given these would interact with private state associated with potentially arbitrary objects I would want us to be careful in order limit its abuse as a WeakMap equivalent.
Here is potentially a way it could work:
Error.captureStackTrace would attempt to define the stack property on the target. If it fails no private field would be added. Depending on timing of the stabilize proposal, if the object is fixed, no private field would be added either.
the getter returns the value of the private field if it exists, or undefined otherwise
the setter would delete the private field and define a data property on the object with the value provided.
I believe this would allow using shared accessor without making them a generic global WeakMap instance or other kind of hidden communication channel.
It's simpler and more straightforward to not use a getter.
In principle with a getter you could defer the work of formatting a stack trace until it's finally consumed.
Bug 1886820 has some discussion around this. Particularly, Matthieu Hoffman has some opinions against getters
The text was updated successfully, but these errors were encountered: