-
-
Notifications
You must be signed in to change notification settings - Fork 413
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
Altering vital properties of builtins #606
Comments
I think one solution is to add a new method on objects: @HalidOdat could you share your thoughts about this? |
Hmmm. I would rename #[inline]
pub(crate) fn insert_property<K>(&mut self, key: K value: V, attribute: Attribute) -> Option<Property>
where
Key: Into<PropertyKey>,
V: Into<Value>,
{
self.insert(key.into(), Property::data_descriptor(value.into(), attribute))
} This way forces us to change all calls to add the attributes: object.insert_property("length", 10, Attribute::READONLY | Attribute::NON_ENUMERABLE | Attribute::PERMANENT); And we remove the What do you think @54k1 ? |
Actually I do not understand why
Yes, this would be better. However, I think it'll also be handy to have a function to insert properties whose attribute is (READONLY, NON_ENUMERABLE, PERMANENT) since there are many properties (>=68) with those attributes. This way code can be simpler at call sites in those cases object.insert_internal_property("length", 1); @HalidOdat what do you think about this? |
If there already was a property with with the same
We have a object.insert_property("length", 10, Attribute::DEFAULT); Having the property be explicit, as the spec does, is nice. If we have multiple places we can factor it out: let attribute = Attribute::READONLY | Attribute::NON_ENUMERABLE | Attribute::PERMANENT;
object.insert_property("length1", 1, attribute);
object.insert_property("length2", 2, attribute);
object.insert_property("length3", 3, attribute);
object.insert_property("length4", 4, attribute);
object.insert_property("length5", 5, attribute);
object.insert_property("length6", 6, attribute); To me the name |
I should have taken a closer look before itself. Sorry about that. We can then have the |
Actually, there's one more method which is used to insert properties: insert_field. In case we want all property inserts to take an explicit attribute as argument, then we must remove it. |
Yes. the |
I was just looking at this again. I think the current #[inline]
pub(crate) fn insert_field<K>(&mut self, key: K value: V, attribute: Attribute) -> Option<Property>
where
K: Into<PropertyKey>,
V: Into<Value>,
{
self.insert(key.into(), Property::data_descriptor(value.into(), attribute))
} Sorry for bringing this naming issue up and dragging this a bit too much 😅. |
Hmmm. I think it's fine to call it |
Describe the bug
Some internal properties (which must not be allowed to set by the user) are being set.
Ex:
Expected behavior
Such things must not alter the contents of a property. For example, in the case of
Object.prototype
, the spec tells the property must be NOT (writable, enumerable, configurable). But it looks like the property is being set using the insert_field method where the attributes of the property are (WRITABLE, ENUMERABLE, CONFIGURABLE).The text was updated successfully, but these errors were encountered: