mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 01:47:34 +00:00
LibJS: Distinguish between omitted descriptor attributes and false ones
When calling Object.defineProperty, there is now a difference between omitting a descriptor attribute and specifying that it is false. For example, "{}" and "{ configurable: false }" will have different attribute values.
This commit is contained in:
parent
5c485d4a1e
commit
5ad5322f6a
8 changed files with 186 additions and 83 deletions
|
@ -37,7 +37,7 @@ const u32 MIN_PACKED_RESIZE_AMOUNT = 20;
|
|||
|
||||
struct ValueAndAttributes {
|
||||
Value value;
|
||||
u8 attributes { default_attributes };
|
||||
PropertyAttributes attributes { default_attributes };
|
||||
};
|
||||
|
||||
class IndexedProperties;
|
||||
|
@ -50,10 +50,10 @@ public:
|
|||
|
||||
virtual bool has_index(u32 index) const = 0;
|
||||
virtual Optional<ValueAndAttributes> get(u32 index) const = 0;
|
||||
virtual void put(u32 index, Value value, u8 attributes = default_attributes) = 0;
|
||||
virtual void put(u32 index, Value value, PropertyAttributes attributes = default_attributes) = 0;
|
||||
virtual void remove(u32 index) = 0;
|
||||
|
||||
virtual void insert(u32 index, Value value, u8 attributes = default_attributes) = 0;
|
||||
virtual void insert(u32 index, Value value, PropertyAttributes attributes = default_attributes) = 0;
|
||||
virtual ValueAndAttributes take_first() = 0;
|
||||
virtual ValueAndAttributes take_last() = 0;
|
||||
|
||||
|
@ -71,10 +71,10 @@ public:
|
|||
|
||||
virtual bool has_index(u32 index) const override;
|
||||
virtual Optional<ValueAndAttributes> get(u32 index) const override;
|
||||
virtual void put(u32 index, Value value, u8 attributes = default_attributes) override;
|
||||
virtual void put(u32 index, Value value, PropertyAttributes attributes = default_attributes) override;
|
||||
virtual void remove(u32 index) override;
|
||||
|
||||
virtual void insert(u32 index, Value value, u8 attributes = default_attributes) override;
|
||||
virtual void insert(u32 index, Value value, PropertyAttributes attributes = default_attributes) override;
|
||||
virtual ValueAndAttributes take_first() override;
|
||||
virtual ValueAndAttributes take_last() override;
|
||||
|
||||
|
@ -98,10 +98,10 @@ public:
|
|||
|
||||
virtual bool has_index(u32 index) const override;
|
||||
virtual Optional<ValueAndAttributes> get(u32 index) const override;
|
||||
virtual void put(u32 index, Value value, u8 attributes = default_attributes) override;
|
||||
virtual void put(u32 index, Value value, PropertyAttributes attributes = default_attributes) override;
|
||||
virtual void remove(u32 index) override;
|
||||
|
||||
virtual void insert(u32 index, Value value, u8 attributes = default_attributes) override;
|
||||
virtual void insert(u32 index, Value value, PropertyAttributes attributes = default_attributes) override;
|
||||
virtual ValueAndAttributes take_first() override;
|
||||
virtual ValueAndAttributes take_last() override;
|
||||
|
||||
|
@ -146,14 +146,14 @@ public:
|
|||
|
||||
bool has_index(u32 index) const { return m_storage->has_index(index); }
|
||||
Optional<ValueAndAttributes> get(Object* this_object, u32 index, bool evaluate_accessors = true) const;
|
||||
void put(Object* this_object, u32 index, Value value, u8 attributes = default_attributes, bool evaluate_accessors = true);
|
||||
void put(Object* this_object, u32 index, Value value, PropertyAttributes attributes = default_attributes, bool evaluate_accessors = true);
|
||||
bool remove(u32 index);
|
||||
|
||||
void insert(u32 index, Value value, u8 attributes = default_attributes);
|
||||
void insert(u32 index, Value value, PropertyAttributes attributes = default_attributes);
|
||||
ValueAndAttributes take_first(Object* this_object);
|
||||
ValueAndAttributes take_last(Object* this_object);
|
||||
|
||||
void append(Value value, u8 attributes = default_attributes) { put(nullptr, array_like_size(), value, attributes, false); }
|
||||
void append(Value value, PropertyAttributes attributes = default_attributes) { put(nullptr, array_like_size(), value, attributes, false); }
|
||||
void append_all(Object* this_object, const IndexedProperties& properties, bool evaluate_accessors = true);
|
||||
|
||||
IndexedPropertyIterator begin(bool skip_empty = true) const { return IndexedPropertyIterator(*this, 0, skip_empty); };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue