Index: src/api.cc |
diff --git a/src/api.cc b/src/api.cc |
index 0b99743a9cc5c9a527718f67a25cfc46ba321e3f..d0859663ef34111effb0fd1df7d7e21d5ec53aa6 100644 |
--- a/src/api.cc |
+++ b/src/api.cc |
@@ -3526,20 +3526,12 @@ static i::MaybeHandle<i::Object> DefineObjectProperty( |
i::Handle<i::JSObject> js_object, i::Handle<i::Object> key, |
i::Handle<i::Object> value, PropertyAttributes attrs) { |
i::Isolate* isolate = js_object->GetIsolate(); |
- // Check if the given key is an array index. |
- uint32_t index = 0; |
- if (key->ToArrayIndex(&index)) { |
- return i::JSObject::SetOwnElementIgnoreAttributes(js_object, index, value, |
- attrs); |
- } |
- |
- i::Handle<i::Name> name; |
- ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, name, |
- i::Object::ToName(isolate, key), |
- i::MaybeHandle<i::Object>()); |
+ bool success = false; |
+ i::LookupIterator it = i::LookupIterator::PropertyOrElement( |
+ isolate, js_object, key, &success, i::LookupIterator::OWN); |
+ if (!success) return i::MaybeHandle<i::Object>(); |
- return i::JSObject::DefinePropertyOrElementIgnoreAttributes(js_object, name, |
- value, attrs); |
+ return i::JSObject::DefineOwnPropertyIgnoreAttributes(&it, value, attrs); |
} |