I find it odd and even a bit bizarre that [[Set]] even checks
frozenness of the prototype for non-getter, non-setter descriptors,
when it only adds own properties. Here's what I propose should change:

1. If the descriptor used by [[Set]] is an accessor property, use that
descriptor directly as is already done.
2. If the descriptor used by [[Set]] is a data property, attempt to
define an own data property on the target object.
3. As already done, [[DefineOwnProperty]] throws when you attempt to
modify a frozen object, even if the old and new properties differ only
in identity.

-----

Isiah Meadows
[email protected]

Looking for web consulting? Or a new website?
Send me an email and we can get started.
www.isiahmeadows.com


On Sat, Mar 24, 2018 at 6:04 PM, /#!/JoePea <[email protected]> wrote:
> Currently, `Object.freeze`ing a prototype affects all objects "inheriting"
> from the prototype when trying to modify props on an inheriting object when
> those same props exist on the prototype, which isn't the behavior that I
> want.
>
> I'd like to prevent a prototype from being modifiable directly, but I still
> want objects that "inherit" from the prototype to work like normal (i.e.
> they can still shadow properties of the prototype and the object will be
> modified directly rather than the prototype).
>
> For example, the following is my problem:
>
> ```js
> prototype.foo = "foo"
>
> Object.freeze( prototype )
>
> const o = Object.create( prototype )
>
> o.foo = "bar" // I want this to work (but it doesn't)
>
> prototype.foo = "baz" // and I want only this to fail because it is
> modifying the prototype directly
> ```
>
> In otherwords, I'd like for inheritance (reading values from the prototype,
> and shadowing the prototype) to work like normal, but I don't want someone
> to grab the prototype and modify it directly and affect all other instances
> of the "class".
>
> Is there some way to do this currently? If not, I'd like to have such a
> feature so that only instances of my classes can be modified, but all
> prototypes in the inheritance are not.
>
> I'm also noting that Object.seal and Object.preventExtensions behave the
> same way (they affect object that inherit from the prototype which is what I
> want to avoid).
>
> /#!/JoePea
>
> _______________________________________________
> es-discuss mailing list
> [email protected]
> https://mail.mozilla.org/listinfo/es-discuss
>
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to