@@ -1696,6 +1696,10 @@ using namespace Js;
1696
1696
template <bool unscopables>
1697
1697
BOOL JavascriptOperators::GetProperty_Internal(Var instance, RecyclableObject* propertyObject, const bool isRoot, PropertyId propertyId, Var* value, ScriptContext* requestContext, PropertyValueInfo* info)
1698
1698
{
1699
+ #if ENABLE_FIXED_FIELDS && DBG
1700
+ DynamicTypeHandler *dynamicTypeHandler = nullptr;
1701
+ #endif
1702
+
1699
1703
if (TaggedNumber::Is(instance))
1700
1704
{
1701
1705
PropertyValueInfo::ClearCacheInfo(info);
@@ -1718,6 +1722,9 @@ using namespace Js;
1718
1722
}
1719
1723
else
1720
1724
{
1725
+ #if ENABLE_FIXED_FIELDS && DBG
1726
+ dynamicTypeHandler = DynamicObject::Is(object) ? DynamicObject::FromVar(object)->GetTypeHandler() : nullptr;
1727
+ #endif
1721
1728
PropertyQueryFlags result = object->GetPropertyQuery(instance, propertyId, value, info, requestContext);
1722
1729
if (result != PropertyQueryFlags::Property_NotFound)
1723
1730
{
@@ -1737,10 +1744,10 @@ using namespace Js;
1737
1744
if (foundProperty)
1738
1745
{
1739
1746
#if ENABLE_FIXED_FIELDS && DBG
1740
- if (DynamicObject::Is(object))
1747
+ // Note: It's valid to check this for the original type handler but not for a new type handler that may have been installed
1748
+ // by a getter that, for instance, deleted and re-added the property.
1749
+ if (dynamicTypeHandler)
1741
1750
{
1742
- DynamicObject* dynamicObject = (DynamicObject*)object;
1743
- DynamicTypeHandler* dynamicTypeHandler = dynamicObject->GetDynamicType()->GetTypeHandler();
1744
1751
Var property;
1745
1752
if (dynamicTypeHandler->CheckFixedProperty(requestContext->GetPropertyName(propertyId), &property, requestContext))
1746
1753
{
@@ -8828,23 +8835,18 @@ using namespace Js;
8828
8835
// ES5 8.12.9.9.c: Convert the property named P of object O from an accessor property to a data property.
8829
8836
// Preserve the existing values of the converted property's [[Configurable]] and [[Enumerable]] attributes
8830
8837
// and set the rest of the property's attributes to their default values.
8831
- // Note: avoid using SetProperty/SetPropertyWithAttributes here because they has undesired side-effects:
8832
- // it calls previous setter and in some cases of attribute values throws.
8833
- // To walk around, call DeleteProperty and then AddProperty.
8834
8838
PropertyAttributes preserveFromObject = currentDescriptor->GetAttributes() & (PropertyConfigurable | PropertyEnumerable);
8835
8839
8836
8840
tempDescriptor.SetAttributes(preserveFromObject, PropertyConfigurable | PropertyEnumerable);
8837
8841
tempDescriptor.MergeFrom(descriptor); // Update only fields specified in 'descriptor'.
8838
8842
Var descriptorValue = descriptor.ValueSpecified() ? descriptor.GetValue() : defaultDataValue;
8839
8843
8840
- // Note: HostDispath'es implementation of DeleteProperty currently throws E_NOTIMPL.
8841
- obj->DeleteProperty(propId, PropertyOperation_None);
8842
- BOOL tempResult = obj->SetPropertyWithAttributes(propId, descriptorValue, tempDescriptor.GetAttributes(), NULL, PropertyOperation_Force);
8843
- Assert(tempResult);
8844
+ BOOL result = DynamicObject::FromVar(obj)->ConvertAccessorToData(propId, descriptorValue, tempDescriptor.GetAttributes());
8844
8845
8845
8846
// At this time we already set value and attributes to desired values,
8846
8847
// thus we can skip step ES5 8.12.9.12 and simply return true.
8847
- return TRUE;
8848
+ Assert(result);
8849
+ return result;
8848
8850
}
8849
8851
}
8850
8852
}
0 commit comments