1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-11 18:20:43 +09:00

LibJS: Fix that proxy always said that it had a [[Construct]] slot

This commit is contained in:
davidot 2021-10-14 02:06:53 +02:00 committed by Linus Groh
parent 1c7c53e5a0
commit 021691753d
Notes: sideshowbarker 2024-07-18 02:21:12 +09:00
2 changed files with 11 additions and 1 deletions

View file

@ -799,6 +799,16 @@ ThrowCompletionOr<Value> ProxyObject::internal_call(Value this_argument, MarkedV
return call(global_object, trap, &m_handler, &m_target, this_argument, arguments_array);
}
bool ProxyObject::has_constructor() const
{
// Note: A Proxy exotic object only has a [[Construct]] internal method if the initial value of
// its [[ProxyTarget]] internal slot is an object that has a [[Construct]] internal method.
if (!is_function())
return false;
return static_cast<FunctionObject&>(m_target).has_constructor();
}
// 10.5.13 [[Construct]] ( argumentsList, newTarget ), https://tc39.es/ecma262/#sec-proxy-object-internal-methods-and-internal-slots-construct-argumentslist-newtarget
ThrowCompletionOr<Object*> ProxyObject::internal_construct(MarkedValueList arguments_list, FunctionObject& new_target)
{

View file

@ -22,7 +22,7 @@ public:
virtual ~ProxyObject() override;
virtual const FlyString& name() const override;
virtual bool has_constructor() const override { return true; }
virtual bool has_constructor() const override;
const Object& target() const { return m_target; }
const Object& handler() const { return m_handler; }