Browse Source

LibJS: Only set receiver value fallback once in Object::get()

Linus Groh 4 năm trước cách đây
mục cha
commit
4f36b6bfbd
1 tập tin đã thay đổi với 3 bổ sung2 xóa
  1. 3 2
      Userland/Libraries/LibJS/Runtime/Object.cpp

+ 3 - 2
Userland/Libraries/LibJS/Runtime/Object.cpp

@@ -696,10 +696,11 @@ Value Object::get(const PropertyName& property_name, Value receiver) const
             return get_by_index(property_index);
     }
 
+    if (receiver.is_empty())
+        receiver = Value(this);
+
     const Object* object = this;
     while (object) {
-        if (receiver.is_empty())
-            receiver = Value(const_cast<Object*>(this));
         auto value = object->get_own_property(property_name, receiver);
         if (vm().exception())
             return {};