summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibJS/Runtime/PropertyDescriptor.cpp42
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