Skip to content

Commit d568804

Browse files
committed
toLocaleString now supports reading object property
1 parent ed98335 commit d568804

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

lib/Runtime/Language/JavascriptConversion.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -701,8 +701,16 @@ using namespace Js;
701701
case TypeIds_Number:
702702
return JavascriptNumber::ToLocaleString(JavascriptNumber::GetValue(aValue), scriptContext);
703703

704-
case TypeIds_String:
705-
return UnsafeVarTo<JavascriptString>(aValue);
704+
case TypeIds_String: {
705+
RecyclableObject* object = VarTo<RecyclableObject>(aValue);
706+
Var value = JavascriptOperators::GetProperty(object, PropertyIds::toLocaleString, scriptContext, NULL);
707+
RecyclableObject* toLocaleStringFunction = VarTo<RecyclableObject>(value);
708+
Var aResult = scriptContext->GetThreadContext()->ExecuteImplicitCall(toLocaleStringFunction, Js::ImplicitCall_ToPrimitive, [=]()->Js::Var
709+
{
710+
return CALL_FUNCTION(scriptContext->GetThreadContext(), toLocaleStringFunction, CallInfo(1), aValue);
711+
});
712+
return UnsafeVarTo<JavascriptString>(aResult);
713+
}
706714

707715
case TypeIds_VariantDate:
708716
// Legacy behavior was to create an empty object and call toLocaleString on it, which would result in this value

0 commit comments

Comments
 (0)