@@ -1699,6 +1699,10 @@ using namespace Js;
16991699 template <bool unscopables>
17001700 BOOL JavascriptOperators::GetProperty_Internal(Var instance, RecyclableObject* propertyObject, const bool isRoot, PropertyId propertyId, Var* value, ScriptContext* requestContext, PropertyValueInfo* info)
17011701 {
1702+ #if ENABLE_FIXED_FIELDS && DBG
1703+ DynamicTypeHandler *dynamicTypeHandler = nullptr;
1704+ #endif
1705+
17021706 if (TaggedNumber::Is(instance))
17031707 {
17041708 PropertyValueInfo::ClearCacheInfo(info);
@@ -1721,6 +1725,9 @@ using namespace Js;
17211725 }
17221726 else
17231727 {
1728+ #if ENABLE_FIXED_FIELDS && DBG
1729+ dynamicTypeHandler = VarIs<DynamicObject>(object) ? VarTo<DynamicObject>(object)->GetTypeHandler() : nullptr;
1730+ #endif
17241731 PropertyQueryFlags result = object->GetPropertyQuery(instance, propertyId, value, info, requestContext);
17251732 if (result != PropertyQueryFlags::Property_NotFound)
17261733 {
@@ -1740,10 +1747,10 @@ using namespace Js;
17401747 if (foundProperty)
17411748 {
17421749#if ENABLE_FIXED_FIELDS && DBG
1743- if (DynamicObject::IsBaseDynamicObject(object))
1750+ // Note: It's valid to check this for the original type handler but not for a new type handler that may have been installed
1751+ // by a getter that, for instance, deleted and re-added the property.
1752+ if (dynamicTypeHandler)
17441753 {
1745- DynamicObject* dynamicObject = (DynamicObject*)object;
1746- DynamicTypeHandler* dynamicTypeHandler = dynamicObject->GetDynamicType()->GetTypeHandler();
17471754 Var property;
17481755 if (dynamicTypeHandler->CheckFixedProperty(requestContext->GetPropertyName(propertyId), &property, requestContext))
17491756 {
@@ -8846,23 +8853,18 @@ using namespace Js;
88468853 // ES5 8.12.9.9.c: Convert the property named P of object O from an accessor property to a data property.
88478854 // Preserve the existing values of the converted property's [[Configurable]] and [[Enumerable]] attributes
88488855 // and set the rest of the property's attributes to their default values.
8849- // Note: avoid using SetProperty/SetPropertyWithAttributes here because they has undesired side-effects:
8850- // it calls previous setter and in some cases of attribute values throws.
8851- // To walk around, call DeleteProperty and then AddProperty.
88528856 PropertyAttributes preserveFromObject = currentDescriptor->GetAttributes() & (PropertyConfigurable | PropertyEnumerable);
88538857
88548858 tempDescriptor.SetAttributes(preserveFromObject, PropertyConfigurable | PropertyEnumerable);
88558859 tempDescriptor.MergeFrom(descriptor); // Update only fields specified in 'descriptor'.
88568860 Var descriptorValue = descriptor.ValueSpecified() ? descriptor.GetValue() : defaultDataValue;
88578861
8858- // Note: HostDispath'es implementation of DeleteProperty currently throws E_NOTIMPL.
8859- obj->DeleteProperty(propId, PropertyOperation_None);
8860- BOOL tempResult = obj->SetPropertyWithAttributes(propId, descriptorValue, tempDescriptor.GetAttributes(), NULL, PropertyOperation_Force);
8861- Assert(tempResult);
8862+ BOOL result = VarTo<DynamicObject>(obj)->ConvertAccessorToData(propId, descriptorValue, tempDescriptor.GetAttributes());
88628863
88638864 // At this time we already set value and attributes to desired values,
88648865 // thus we can skip step ES5 8.12.9.12 and simply return true.
8865- return TRUE;
8866+ Assert(result);
8867+ return result;
88668868 }
88678869 }
88688870 }
0 commit comments