summaryrefslogtreecommitdiff
path: root/Libraries/LibWeb/Bindings/NavigatorObject.cpp
diff options
context:
space:
mode:
authorMatthew Olsson <matthewcolsson@gmail.com>2020-05-27 11:35:09 -0700
committerAndreas Kling <kling@serenityos.org>2020-05-28 17:17:13 +0200
commit5ae9419a069f8180197df14447b1a23f1cf9411d (patch)
treeeee7680898e6520632343d36a32ac05c82f4614b /Libraries/LibWeb/Bindings/NavigatorObject.cpp
parentcc54974431abe402d4c6ac3c50df3b6d4353d507 (diff)
downloadserenity-5ae9419a069f8180197df14447b1a23f1cf9411d.zip
LibJS: Object index properties have descriptors; Handle sparse indices
This patch adds an IndexedProperties object for storing indexed properties within an Object. This accomplishes two goals: indexed properties now have an associated descriptor, and objects now gracefully handle sparse properties. The IndexedProperties class is a wrapper around two other classes, one for simple indexed properties storage, and one for general indexed property storage. Simple indexed property storage is the common-case, and is simply a vector of properties which all have attributes of default_attributes (writable, enumerable, and configurable). General indexed property storage is for a collection of indexed properties where EITHER one or more properties have attributes other than default_attributes OR there is a property with a large index (in particular, large is '200' or higher). Indexed properties are now treated relatively the same as storage within the various Object methods. Additionally, there is a custom iterator class for IndexedProperties which makes iteration easy. The iterator skips empty values by default, but can be configured otherwise. Likewise, it evaluates getters by default, but can be set not to.
Diffstat (limited to 'Libraries/LibWeb/Bindings/NavigatorObject.cpp')
-rw-r--r--Libraries/LibWeb/Bindings/NavigatorObject.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/Libraries/LibWeb/Bindings/NavigatorObject.cpp b/Libraries/LibWeb/Bindings/NavigatorObject.cpp
index 54d6077b06..6d018e69d5 100644
--- a/Libraries/LibWeb/Bindings/NavigatorObject.cpp
+++ b/Libraries/LibWeb/Bindings/NavigatorObject.cpp
@@ -38,12 +38,12 @@ NavigatorObject::NavigatorObject()
: Object(interpreter().global_object().object_prototype())
{
auto* languages = JS::Array::create(interpreter().global_object());
- languages->elements().append(js_string(heap(), "en-US"));
+ languages->indexed_properties().append(js_string(heap(), "en-US"));
define_property("appCodeName", js_string(heap(), "Mozilla"));
define_property("appName", js_string(heap(), "Netscape"));
define_property("appVersion", js_string(heap(), "4.0"));
- define_property("language", languages->elements().first());
+ define_property("language", languages->get(0));
define_property("languages", languages);
define_property("platform", js_string(heap(), "SerenityOS"));
define_property("product", js_string(heap(), "Gecko"));