diff options
author | Jack Karamanian <karamanian.jack@gmail.com> | 2020-05-30 00:15:17 -0500 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-05-30 10:33:24 +0200 |
commit | 1110b1b444d0b9a71820d9c7520c2d81e6dcdf24 (patch) | |
tree | 757c67d8335c7190233ae7957c3aeaa27b1823d2 /Libraries | |
parent | 45ccd9f8d9dae34120d3001f1885f2b521b7bba9 (diff) | |
download | serenity-1110b1b444d0b9a71820d9c7520c2d81e6dcdf24.zip |
LibJS: Don't define the "prototype" property for arrow functions
Diffstat (limited to 'Libraries')
-rw-r--r-- | Libraries/LibJS/Runtime/ScriptFunction.cpp | 3 | ||||
-rw-r--r-- | Libraries/LibJS/Tests/arrow-functions.js | 4 |
2 files changed, 6 insertions, 1 deletions
diff --git a/Libraries/LibJS/Runtime/ScriptFunction.cpp b/Libraries/LibJS/Runtime/ScriptFunction.cpp index 5d0857823f..5828bcdde3 100644 --- a/Libraries/LibJS/Runtime/ScriptFunction.cpp +++ b/Libraries/LibJS/Runtime/ScriptFunction.cpp @@ -61,7 +61,8 @@ ScriptFunction::ScriptFunction(const FlyString& name, const Statement& body, Vec , m_function_length(m_function_length) , m_is_arrow_function(is_arrow_function) { - define_property("prototype", Object::create_empty(interpreter(), interpreter().global_object()), 0); + if (!is_arrow_function) + define_property("prototype", Object::create_empty(interpreter(), interpreter().global_object()), 0); define_native_property("length", length_getter, nullptr, Attribute::Configurable); define_native_property("name", name_getter, nullptr, Attribute::Configurable); } diff --git a/Libraries/LibJS/Tests/arrow-functions.js b/Libraries/LibJS/Tests/arrow-functions.js index d34a7836f2..e224415ded 100644 --- a/Libraries/LibJS/Tests/arrow-functions.js +++ b/Libraries/LibJS/Tests/arrow-functions.js @@ -77,6 +77,10 @@ try { assert(foobar.x.y() === foobar); assert(foobar.x.z() === foobar.x); + var Baz = () => {}; + + assert(Baz.prototype === undefined); + (() => { "use strict"; assert(isStrictMode()); |