mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 18:07:34 +00:00
LibJS: Implement correct attributes for (almost) all properties
Added the ability to include a u8 attributes parameter with all of the various put methods in the Object class. They can be omitted, in which case it defaults to "Writable | Enumerable | Configurable", just like before this commit. All of the attribute values for each property were gathered from SpiderMonkey in the Firefox console. Some properties (e.g. all of the canvas element properties) have undefined property descriptors... not quite sure what that means. Those were left as the default specified above.
This commit is contained in:
parent
c4d05049c4
commit
23ec578a01
26 changed files with 189 additions and 169 deletions
|
@ -32,10 +32,13 @@
|
|||
#include <LibJS/Runtime/Cell.h>
|
||||
#include <LibJS/Runtime/PrimitiveString.h>
|
||||
#include <LibJS/Runtime/PropertyName.h>
|
||||
#include <LibJS/Runtime/Shape.h>
|
||||
#include <LibJS/Runtime/Value.h>
|
||||
|
||||
namespace JS {
|
||||
|
||||
const u8 default_attributes = Attribute::Configurable | Attribute::Writable | Attribute::Enumerable;
|
||||
|
||||
class Object : public Cell {
|
||||
public:
|
||||
static Object* create_empty(Interpreter&, GlobalObject&);
|
||||
|
@ -52,9 +55,9 @@ public:
|
|||
Value get(const FlyString& property_name) const;
|
||||
Value get(PropertyName) const;
|
||||
|
||||
virtual void put_by_index(i32 property_index, Value);
|
||||
void put(const FlyString& property_name, Value);
|
||||
void put(PropertyName, Value);
|
||||
virtual void put_by_index(i32 property_index, Value, u8 attributes = default_attributes);
|
||||
void put(const FlyString& property_name, Value, u8 attributes = default_attributes);
|
||||
void put(PropertyName, Value, u8 attributes = default_attributes);
|
||||
|
||||
Value get_own_property(const Object& this_object, const FlyString& property_name) const;
|
||||
|
||||
|
@ -65,8 +68,8 @@ public:
|
|||
|
||||
void put_own_property(Object& this_object, const FlyString& property_name, u8 attributes, Value, PutOwnPropertyMode);
|
||||
|
||||
void put_native_function(const FlyString& property_name, AK::Function<Value(Interpreter&)>, i32 length = 0);
|
||||
void put_native_property(const FlyString& property_name, AK::Function<Value(Interpreter&)> getter, AK::Function<void(Interpreter&, Value)> setter);
|
||||
void put_native_function(const FlyString& property_name, AK::Function<Value(Interpreter&)>, i32 length = 0, u8 attribute = default_attributes);
|
||||
void put_native_property(const FlyString& property_name, AK::Function<Value(Interpreter&)> getter, AK::Function<void(Interpreter&, Value)> setter, u8 attribute = default_attributes);
|
||||
|
||||
virtual bool is_array() const { return false; }
|
||||
virtual bool is_boolean() const { return false; }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue