summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2021-06-20 17:08:29 +0100
committerLinus Groh <mail@linusgroh.de>2021-06-20 17:52:09 +0100
commite9388408db8cf939539975ed8df3a66806862ee2 (patch)
treec3c2c873e25f4bdb6cf25251a32cb442b3c048d8 /Userland
parentf2aa5efbeb6884b51b22319c30fe69ebc09eff9f (diff)
downloadserenity-e9388408db8cf939539975ed8df3a66806862ee2.zip
LibJS: Implement support for the [[IsHTMLDDA]] internal slot
Best regards from Annex B and document.all :^)
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibJS/Runtime/Object.h3
-rw-r--r--Userland/Libraries/LibJS/Runtime/Value.cpp12
2 files changed, 15 insertions, 0 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/Object.h b/Userland/Libraries/LibJS/Runtime/Object.h
index 215ae7d4d3..cfdfb9b8d0 100644
--- a/Userland/Libraries/LibJS/Runtime/Object.h
+++ b/Userland/Libraries/LibJS/Runtime/Object.h
@@ -110,6 +110,9 @@ public:
virtual bool is_native_function() const { return false; }
virtual bool is_lexical_environment() const { return false; }
+ // B.3.7 The [[IsHTMLDDA]] Internal Slot, https://tc39.es/ecma262/#sec-IsHTMLDDA-internal-slot
+ virtual bool is_htmldda() const { return false; }
+
virtual const char* class_name() const override { return "Object"; }
virtual void visit_edges(Cell::Visitor&) override;
diff --git a/Userland/Libraries/LibJS/Runtime/Value.cpp b/Userland/Libraries/LibJS/Runtime/Value.cpp
index 1f3de02866..8461966fac 100644
--- a/Userland/Libraries/LibJS/Runtime/Value.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Value.cpp
@@ -275,6 +275,9 @@ String Value::typeof() const
case Value::Type::String:
return "string";
case Value::Type::Object:
+ // B.3.7.3 Changes to the typeof Operator, https://tc39.es/ecma262/#sec-IsHTMLDDA-internal-slot-typeof
+ if (as_object().is_htmldda())
+ return "undefined";
if (is_function())
return "function";
return "object";
@@ -383,6 +386,9 @@ bool Value::to_boolean() const
case Type::BigInt:
return m_value.as_bigint->big_integer() != BIGINT_ZERO;
case Type::Object:
+ // B.3.7.1 Changes to ToBoolean, https://tc39.es/ecma262/#sec-IsHTMLDDA-internal-slot-to-boolean
+ if (m_value.as_object->is_htmldda())
+ return false;
return true;
default:
VERIFY_NOT_REACHED();
@@ -1329,6 +1335,12 @@ bool abstract_eq(GlobalObject& global_object, Value lhs, Value rhs)
if (lhs.is_nullish() && rhs.is_nullish())
return true;
+ // B.3.7.2 Changes to IsLooselyEqual, https://tc39.es/ecma262/#sec-IsHTMLDDA-internal-slot-aec
+ if (lhs.is_object() && lhs.as_object().is_htmldda() && rhs.is_nullish())
+ return true;
+ if (lhs.is_nullish() && rhs.is_object() && rhs.as_object().is_htmldda())
+ return true;
+
if (lhs.is_number() && rhs.is_string())
return abstract_eq(global_object, lhs, rhs.to_number(global_object));