From fc1168a3b3ae4d1bfdf3a0fb0fdb35a9dc6dde7a Mon Sep 17 00:00:00 2001 From: davidot Date: Sun, 13 Jun 2021 18:11:19 +0200 Subject: [PATCH] LibJS: Add Array.prototype.@@unscopables --- .../Libraries/LibJS/Runtime/ArrayPrototype.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Userland/Libraries/LibJS/Runtime/ArrayPrototype.cpp b/Userland/Libraries/LibJS/Runtime/ArrayPrototype.cpp index 91f61a1d7ce..d1ee2d1aa7b 100644 --- a/Userland/Libraries/LibJS/Runtime/ArrayPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/ArrayPrototype.cpp @@ -2,6 +2,7 @@ * Copyright (c) 2020, Andreas Kling * Copyright (c) 2020-2021, Linus Groh * Copyright (c) 2020, Marcin Gasperowicz + * Copyright (c) 2021, David Tuin * * SPDX-License-Identifier: BSD-2-Clause */ @@ -72,6 +73,22 @@ void ArrayPrototype::initialize(GlobalObject& global_object) // evaluates to true // 23.1.3.33 Array.prototype [ @@iterator ] ( ), https://tc39.es/ecma262/#sec-array.prototype-@@iterator define_property(vm.well_known_symbol_iterator(), get(vm.names.values), attr); + + // 23.1.3.34 Array.prototype [ @@unscopables ], https://tc39.es/ecma262/#sec-array.prototype-@@unscopables + Object* unscopable_list = create_empty(global_object); + unscopable_list->set_prototype(nullptr); + unscopable_list->put(vm.names.copyWithin, Value(true)); + unscopable_list->put(vm.names.entries, Value(true)); + unscopable_list->put(vm.names.fill, Value(true)); + unscopable_list->put(vm.names.find, Value(true)); + unscopable_list->put(vm.names.findIndex, Value(true)); + unscopable_list->put(vm.names.flat, Value(true)); + unscopable_list->put(vm.names.flatMap, Value(true)); + unscopable_list->put(vm.names.includes, Value(true)); + unscopable_list->put(vm.names.keys, Value(true)); + unscopable_list->put(vm.names.values, Value(true)); + + define_property(vm.well_known_symbol_unscopables(), unscopable_list, Attribute::Configurable); } ArrayPrototype::~ArrayPrototype()