diff options
author | Linus Groh <mail@linusgroh.de> | 2022-05-01 01:38:21 +0200 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2022-05-01 22:47:38 +0200 |
commit | 8cbd25f553d19a69370947d7a02eaade35cf0c8d (patch) | |
tree | 4594e9a1220c46be119122f3a8d65b4dc69e9377 /Userland | |
parent | 07ac8b702146609c82c13793a073a306cdd901d8 (diff) | |
download | serenity-8cbd25f553d19a69370947d7a02eaade35cf0c8d.zip |
LibJS: Simplify Is{Accessor,Data,Generic}Descriptor AOs
This is an editorial change in the ECMA-262 spec.
See: https://github.com/tc39/ecma262/commit/1c7ae4b
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Libraries/LibJS/Runtime/PropertyDescriptor.cpp | 42 |
1 files changed, 27 insertions, 15 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/PropertyDescriptor.cpp b/Userland/Libraries/LibJS/Runtime/PropertyDescriptor.cpp index 270420aebc..1a93267bdc 100644 --- a/Userland/Libraries/LibJS/Runtime/PropertyDescriptor.cpp +++ b/Userland/Libraries/LibJS/Runtime/PropertyDescriptor.cpp @@ -18,12 +18,16 @@ bool PropertyDescriptor::is_accessor_descriptor() const { // 1. If Desc is undefined, return false. - // 2. If Desc does not have a [[Get]] field and Desc does not have a [[Set]] field, return false. - if (!get.has_value() && !set.has_value()) - return false; + // 2. If Desc has a [[Get]] field, return true. + if (get.has_value()) + return true; - // 3. Return true. - return true; + // 3. If Desc has a [[Set]] field, return true. + if (set.has_value()) + return true; + + // 4. Return false. + return false; } // 6.2.5.2 IsDataDescriptor ( Desc ), https://tc39.es/ecma262/#sec-isdatadescriptor @@ -31,12 +35,16 @@ bool PropertyDescriptor::is_data_descriptor() const { // 1. If Desc is undefined, return false. - // 2. If Desc does not have a [[Value]] field and Desc does not have a [[Writable]] field, return false. - if (!value.has_value() && !writable.has_value()) - return false; + // 2. If Desc has a [[Value]] field, return true. + if (value.has_value()) + return true; - // 3. Return true. - return true; + // 3. If Desc has a [[Writable]] field, return true. + if (writable.has_value()) + return true; + + // 4. Return false. + return false; } // 6.2.5.3 IsGenericDescriptor ( Desc ), https://tc39.es/ecma262/#sec-isgenericdescriptor @@ -44,12 +52,16 @@ bool PropertyDescriptor::is_generic_descriptor() const { // 1. If Desc is undefined, return false. - // 2. If IsAccessorDescriptor(Desc) and IsDataDescriptor(Desc) are both false, return true. - if (!is_accessor_descriptor() && !is_data_descriptor()) - return true; + // 2. If IsAccessorDescriptor(Desc) is true, return false. + if (is_accessor_descriptor()) + return false; - // 3. Return false. - return false; + // 3. If IsDataDescriptor(Desc) is true, return false. + if (is_data_descriptor()) + return false; + + // 4. Return true. + return true; } // 6.2.5.4 FromPropertyDescriptor ( Desc ), https://tc39.es/ecma262/#sec-frompropertydescriptor |