mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 21:27:34 +00:00
LibJS: Implement support for the [[IsHTMLDDA]] internal slot
Best regards from Annex B and document.all :^)
This commit is contained in:
parent
f2aa5efbeb
commit
e9388408db
2 changed files with 15 additions and 0 deletions
|
@ -110,6 +110,9 @@ public:
|
||||||
virtual bool is_native_function() const { return false; }
|
virtual bool is_native_function() const { return false; }
|
||||||
virtual bool is_lexical_environment() 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 const char* class_name() const override { return "Object"; }
|
||||||
virtual void visit_edges(Cell::Visitor&) override;
|
virtual void visit_edges(Cell::Visitor&) override;
|
||||||
|
|
||||||
|
|
|
@ -275,6 +275,9 @@ String Value::typeof() const
|
||||||
case Value::Type::String:
|
case Value::Type::String:
|
||||||
return "string";
|
return "string";
|
||||||
case Value::Type::Object:
|
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())
|
if (is_function())
|
||||||
return "function";
|
return "function";
|
||||||
return "object";
|
return "object";
|
||||||
|
@ -383,6 +386,9 @@ bool Value::to_boolean() const
|
||||||
case Type::BigInt:
|
case Type::BigInt:
|
||||||
return m_value.as_bigint->big_integer() != BIGINT_ZERO;
|
return m_value.as_bigint->big_integer() != BIGINT_ZERO;
|
||||||
case Type::Object:
|
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;
|
return true;
|
||||||
default:
|
default:
|
||||||
VERIFY_NOT_REACHED();
|
VERIFY_NOT_REACHED();
|
||||||
|
@ -1329,6 +1335,12 @@ bool abstract_eq(GlobalObject& global_object, Value lhs, Value rhs)
|
||||||
if (lhs.is_nullish() && rhs.is_nullish())
|
if (lhs.is_nullish() && rhs.is_nullish())
|
||||||
return true;
|
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())
|
if (lhs.is_number() && rhs.is_string())
|
||||||
return abstract_eq(global_object, lhs, rhs.to_number(global_object));
|
return abstract_eq(global_object, lhs, rhs.to_number(global_object));
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue