diff options
author | Jack Karamanian <karamanian.jack@gmail.com> | 2020-06-08 13:24:15 -0500 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-06-29 17:54:54 +0200 |
commit | 949bffdc933a5e992c7ae09fa7d2031abd343276 (patch) | |
tree | 28fcf64fcb91ad8b01c2e7cfedc97bc9b05eb169 /Libraries/LibJS/Runtime | |
parent | f833362536df1d7df68d1c47811f81f977d10fd3 (diff) | |
download | serenity-949bffdc933a5e992c7ae09fa7d2031abd343276.zip |
LibJS: Define the "constructor" property on ScriptFunction's prototype
and set it to the current function
Diffstat (limited to 'Libraries/LibJS/Runtime')
-rw-r--r-- | Libraries/LibJS/Runtime/ScriptFunction.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/Libraries/LibJS/Runtime/ScriptFunction.cpp b/Libraries/LibJS/Runtime/ScriptFunction.cpp index 650d7937da..11fa9c5da0 100644 --- a/Libraries/LibJS/Runtime/ScriptFunction.cpp +++ b/Libraries/LibJS/Runtime/ScriptFunction.cpp @@ -66,8 +66,11 @@ ScriptFunction::ScriptFunction(GlobalObject& global_object, const FlyString& nam void ScriptFunction::initialize(Interpreter& interpreter, GlobalObject& global_object) { Function::initialize(interpreter, global_object); - if (!m_is_arrow_function) - define_property("prototype", Object::create_empty(interpreter, global_object), 0); + if (!is_arrow_function) { + Object* prototype = Object::create_empty(interpreter(), interpreter().global_object()); + prototype->define_property("constructor", this, Attribute::Writable | Attribute::Configurable); + define_property("prototype", prototype, 0); + } define_native_property("length", length_getter, nullptr, Attribute::Configurable); define_native_property("name", name_getter, nullptr, Attribute::Configurable); } |