1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 02:27:43 +00:00

LibJS: Add Object::get_without_side_effects()

Similar to Value::to_string_without_side_effects() this is mostly a
regular object property lookup, but with the guarantee that it will be
side-effect free, i.e. no accessors or native property functions will
be called. This is needed when we want to access user-controlled object
properties for debug logging, for example. The specific use case will be
error objects which will soon no longer have internal name/message
properties, so we need to guarantee that printing an error, which may
already be the result of an exception, won't blow up in our face :^)
This commit is contained in:
Linus Groh 2021-04-11 22:52:25 +02:00 committed by Andreas Kling
parent 9ec4defdd2
commit 6e9eb0a284
4 changed files with 23 additions and 11 deletions

View file

@ -55,7 +55,7 @@ public:
virtual Optional<PropertyDescriptor> get_own_property_descriptor(const PropertyName&) const override;
virtual bool define_property(const StringOrSymbol& property_name, const Object& descriptor, bool throw_exceptions = true) override;
virtual bool has_property(const PropertyName& name) const override;
virtual Value get(const PropertyName& name, Value receiver) const override;
virtual Value get(const PropertyName& name, Value receiver, bool without_side_effects = false) const override;
virtual bool put(const PropertyName& name, Value value, Value receiver) override;
virtual bool delete_property(const PropertyName& name) override;