From 531fdb2e8211a985a38d65e1f7f362cc6d3b644e Mon Sep 17 00:00:00 2001 From: Matthew Olsson Date: Sat, 11 Jul 2020 07:58:56 -0700 Subject: [PATCH] LibJS: Prefer "define_property" over "put" --- Libraries/LibJS/Runtime/ArrayPrototype.cpp | 2 +- Libraries/LibJS/Runtime/IteratorOperations.cpp | 4 ++-- Libraries/LibJS/Runtime/JSONObject.cpp | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Libraries/LibJS/Runtime/ArrayPrototype.cpp b/Libraries/LibJS/Runtime/ArrayPrototype.cpp index 76a85e85f6..f5408e5c79 100644 --- a/Libraries/LibJS/Runtime/ArrayPrototype.cpp +++ b/Libraries/LibJS/Runtime/ArrayPrototype.cpp @@ -182,7 +182,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::map) for_each_item(interpreter, global_object, "map", [&](auto index, auto, auto callback_result) { if (interpreter.exception()) return IterationDecision::Break; - new_array->put(index, callback_result); + new_array->define_property(index, callback_result); return IterationDecision::Continue; }); return Value(new_array); diff --git a/Libraries/LibJS/Runtime/IteratorOperations.cpp b/Libraries/LibJS/Runtime/IteratorOperations.cpp index 1f4a51b2c2..b5f98239af 100644 --- a/Libraries/LibJS/Runtime/IteratorOperations.cpp +++ b/Libraries/LibJS/Runtime/IteratorOperations.cpp @@ -112,8 +112,8 @@ void iterator_close(Object& iterator) Value create_iterator_result_object(Interpreter& interpreter, GlobalObject& global_object, Value value, bool done) { auto* object = Object::create_empty(interpreter, global_object); - object->put("value", value); - object->put("done", Value(done)); + object->define_property("value", value); + object->define_property("done", Value(done)); return object; } diff --git a/Libraries/LibJS/Runtime/JSONObject.cpp b/Libraries/LibJS/Runtime/JSONObject.cpp index 3b88d5e0ab..b333e6a984 100644 --- a/Libraries/LibJS/Runtime/JSONObject.cpp +++ b/Libraries/LibJS/Runtime/JSONObject.cpp @@ -433,7 +433,7 @@ Object* JSONObject::parse_json_object(Interpreter& interpreter, GlobalObject& gl { auto* object = Object::create_empty(interpreter, global_object); json_object.for_each_member([&](auto& key, auto& value) { - object->put(key, parse_json_value(interpreter, global_object, value)); + object->define_property(key, parse_json_value(interpreter, global_object, value)); }); return object; } @@ -443,7 +443,7 @@ Array* JSONObject::parse_json_array(Interpreter& interpreter, GlobalObject& glob auto* array = Array::create(global_object); size_t index = 0; json_array.for_each([&](auto& value) { - array->put(index++, parse_json_value(interpreter, global_object, value)); + array->define_property(index++, parse_json_value(interpreter, global_object, value)); }); return array; }