Skip to content

Commit 168bb7d

Browse files
committed
Fix Issue #3368: Symbol.species.toString() shouldn't have bracket around the name
1 parent d5cbb9d commit 168bb7d

File tree

3 files changed

+18
-36
lines changed

3 files changed

+18
-36
lines changed

lib/Runtime/Base/JnDirectFields.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ ENTRY_SYMBOL(_symbolMatch, _u("Symbol.match"))
3838
ENTRY_SYMBOL(_symbolReplace, _u("Symbol.replace"))
3939
ENTRY_SYMBOL(_symbolSearch, _u("Symbol.search"))
4040
ENTRY_SYMBOL(_symbolSplit, _u("Symbol.split"))
41-
ENTRY_SYMBOL(_symbolSpecies, _u("[Symbol.species]"))
41+
ENTRY_SYMBOL(_symbolSpecies, _u("Symbol.species"))
4242
ENTRY_SYMBOL(_symbolToPrimitive, _u("Symbol.toPrimitive"))
4343
ENTRY_SYMBOL(_symbolToStringTag, _u("Symbol.toStringTag"))
4444
ENTRY_SYMBOL(_symbolUnscopables, _u("Symbol.unscopables"))

lib/Runtime/Library/JavascriptLibrary.cpp

Lines changed: 16 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1637,10 +1637,7 @@ namespace Js
16371637

16381638
library->AddMember(arrayConstructor, PropertyIds::length, TaggedInt::ToVarUnchecked(1), PropertyNone);
16391639
library->AddMember(arrayConstructor, PropertyIds::prototype, scriptContext->GetLibrary()->arrayPrototype, PropertyNone);
1640-
if (scriptContext->GetConfig()->IsES6SpeciesEnabled())
1641-
{
1642-
library->AddAccessorsToLibraryObject(arrayConstructor, PropertyIds::_symbolSpecies, &JavascriptArray::EntryInfo::GetterSymbolSpecies, nullptr);
1643-
}
1640+
library->AddSpeciesAccessorsToLibraryObject(arrayConstructor, &JavascriptArray::EntryInfo::GetterSymbolSpecies);
16441641

16451642
if (scriptContext->GetConfig()->IsES6FunctionNameEnabled())
16461643
{
@@ -1804,8 +1801,7 @@ namespace Js
18041801
JavascriptLibrary* library = sharedArrayBufferConstructor->GetLibrary();
18051802
library->AddMember(sharedArrayBufferConstructor, PropertyIds::length, TaggedInt::ToVarUnchecked(1), PropertyNone);
18061803
library->AddMember(sharedArrayBufferConstructor, PropertyIds::prototype, scriptContext->GetLibrary()->sharedArrayBufferPrototype, PropertyNone);
1807-
1808-
library->AddAccessorsToLibraryObject(sharedArrayBufferConstructor, PropertyIds::_symbolSpecies, &SharedArrayBuffer::EntryInfo::GetterSymbolSpecies, nullptr);
1804+
library->AddSpeciesAccessorsToLibraryObject(sharedArrayBufferConstructor, &SharedArrayBuffer::EntryInfo::GetterSymbolSpecies);
18091805

18101806
if (scriptContext->GetConfig()->IsES6FunctionNameEnabled())
18111807
{
@@ -1874,11 +1870,7 @@ namespace Js
18741870
JavascriptLibrary* library = arrayBufferConstructor->GetLibrary();
18751871
library->AddMember(arrayBufferConstructor, PropertyIds::length, TaggedInt::ToVarUnchecked(1), PropertyNone);
18761872
library->AddMember(arrayBufferConstructor, PropertyIds::prototype, scriptContext->GetLibrary()->arrayBufferPrototype, PropertyNone);
1877-
1878-
if (scriptContext->GetConfig()->IsES6SpeciesEnabled())
1879-
{
1880-
library->AddAccessorsToLibraryObject(arrayBufferConstructor, PropertyIds::_symbolSpecies, &ArrayBuffer::EntryInfo::GetterSymbolSpecies, nullptr);
1881-
}
1873+
library->AddSpeciesAccessorsToLibraryObject(arrayBufferConstructor, &ArrayBuffer::EntryInfo::GetterSymbolSpecies);
18821874

18831875
if (scriptContext->GetConfig()->IsES6FunctionNameEnabled())
18841876
{
@@ -1988,10 +1980,7 @@ namespace Js
19881980

19891981
library->AddFunctionToLibraryObject(typedArrayConstructor, PropertyIds::from, &TypedArrayBase::EntryInfo::From, 1);
19901982
library->AddFunctionToLibraryObject(typedArrayConstructor, PropertyIds::of, &TypedArrayBase::EntryInfo::Of, 0);
1991-
if (scriptContext->GetConfig()->IsES6SpeciesEnabled())
1992-
{
1993-
library->AddAccessorsToLibraryObject(typedArrayConstructor, PropertyIds::_symbolSpecies, &TypedArrayBase::EntryInfo::GetterSymbolSpecies, nullptr);
1994-
}
1983+
library->AddSpeciesAccessorsToLibraryObject(typedArrayConstructor, &TypedArrayBase::EntryInfo::GetterSymbolSpecies);
19951984

19961985
typedArrayConstructor->SetHasNoEnumerableProperties(true);
19971986

@@ -2349,11 +2338,7 @@ namespace Js
23492338
ScriptContext* scriptContext = promiseConstructor->GetScriptContext();
23502339
library->AddMember(promiseConstructor, PropertyIds::length, TaggedInt::ToVarUnchecked(1), PropertyNone);
23512340
library->AddMember(promiseConstructor, PropertyIds::prototype, library->promisePrototype, PropertyNone);
2352-
2353-
if (scriptContext->GetConfig()->IsES6SpeciesEnabled())
2354-
{
2355-
library->AddAccessorsToLibraryObject(promiseConstructor, PropertyIds::_symbolSpecies, &JavascriptPromise::EntryInfo::GetterSymbolSpecies, nullptr);
2356-
}
2341+
library->AddSpeciesAccessorsToLibraryObject(promiseConstructor, &JavascriptPromise::EntryInfo::GetterSymbolSpecies);
23572342

23582343
if (scriptContext->GetConfig()->IsES6FunctionNameEnabled())
23592344
{
@@ -4422,11 +4407,7 @@ namespace Js
44224407
// so that the update is in sync with profiler
44234408
library->AddMember(regexConstructor, PropertyIds::length, TaggedInt::ToVarUnchecked(2), PropertyNone);
44244409
library->AddMember(regexConstructor, PropertyIds::prototype, library->regexPrototype, PropertyNone);
4425-
4426-
if (scriptContext->GetConfig()->IsES6SpeciesEnabled())
4427-
{
4428-
library->AddAccessorsToLibraryObject(regexConstructor, PropertyIds::_symbolSpecies, &JavascriptRegExp::EntryInfo::GetterSymbolSpecies, nullptr);
4429-
}
4410+
library->AddSpeciesAccessorsToLibraryObject(regexConstructor, &JavascriptRegExp::EntryInfo::GetterSymbolSpecies);
44304411

44314412
if (scriptContext->GetConfig()->IsES6FunctionNameEnabled())
44324413
{
@@ -4654,11 +4635,7 @@ namespace Js
46544635
ScriptContext* scriptContext = mapConstructor->GetScriptContext();
46554636
library->AddMember(mapConstructor, PropertyIds::length, TaggedInt::ToVarUnchecked(0), PropertyNone);
46564637
library->AddMember(mapConstructor, PropertyIds::prototype, library->mapPrototype, PropertyNone);
4657-
4658-
if (scriptContext->GetConfig()->IsES6SpeciesEnabled())
4659-
{
4660-
library->AddAccessorsToLibraryObject(mapConstructor, PropertyIds::_symbolSpecies, &JavascriptMap::EntryInfo::GetterSymbolSpecies, nullptr);
4661-
}
4638+
library->AddSpeciesAccessorsToLibraryObject(mapConstructor, &JavascriptMap::EntryInfo::GetterSymbolSpecies);
46624639

46634640
if (scriptContext->GetConfig()->IsES6FunctionNameEnabled())
46644641
{
@@ -4713,11 +4690,7 @@ namespace Js
47134690
ScriptContext* scriptContext = setConstructor->GetScriptContext();
47144691
library->AddMember(setConstructor, PropertyIds::length, TaggedInt::ToVarUnchecked(0), PropertyNone);
47154692
library->AddMember(setConstructor, PropertyIds::prototype, library->setPrototype, PropertyNone);
4716-
4717-
if (scriptContext->GetConfig()->IsES6SpeciesEnabled())
4718-
{
4719-
library->AddAccessorsToLibraryObject(setConstructor, PropertyIds::_symbolSpecies, &JavascriptSet::EntryInfo::GetterSymbolSpecies, nullptr);
4720-
}
4693+
library->AddSpeciesAccessorsToLibraryObject(setConstructor, &JavascriptSet::EntryInfo::GetterSymbolSpecies);
47214694

47224695
if (scriptContext->GetConfig()->IsES6FunctionNameEnabled())
47234696
{
@@ -5142,6 +5115,14 @@ namespace Js
51425115
AddAccessorsToLibraryObject(object, propertyId, getterFunction, setterFunction);
51435116
}
51445117

5118+
void JavascriptLibrary::AddSpeciesAccessorsToLibraryObject(DynamicObject* object, FunctionInfo * getterFunctionInfo)
5119+
{
5120+
if (scriptContext->GetConfig()->IsES6SpeciesEnabled())
5121+
{
5122+
AddAccessorsToLibraryObjectWithName(object, PropertyIds::_symbolSpecies, PropertyIds::_RuntimeFunctionNameId_species, getterFunctionInfo, nullptr);
5123+
}
5124+
}
5125+
51455126
RuntimeFunction* JavascriptLibrary::CreateGetterFunction(PropertyId nameId, FunctionInfo* functionInfo)
51465127
{
51475128
Var name_withGetPrefix = LiteralString::Concat(LiteralString::NewCopySz(_u("get "), scriptContext), scriptContext->GetPropertyString(nameId));

lib/Runtime/Library/JavascriptLibrary.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,7 @@ namespace Js
574574
void AddAccessorsToLibraryObject(DynamicObject* object, PropertyId propertyId, FunctionInfo * getterFunctionInfo, FunctionInfo * setterFunctionInfo);
575575
void AddAccessorsToLibraryObject(DynamicObject* object, PropertyId propertyId, RecyclableObject * getterFunction, RecyclableObject * setterFunction);
576576
void AddAccessorsToLibraryObjectWithName(DynamicObject* object, PropertyId propertyId, PropertyId nameId, FunctionInfo * getterFunctionInfo, FunctionInfo * setterFunction);
577+
void AddSpeciesAccessorsToLibraryObject(DynamicObject* object, FunctionInfo * getterFunctionInfo);
577578
RuntimeFunction * CreateGetterFunction(PropertyId nameId, FunctionInfo* functionInfo);
578579
RuntimeFunction * CreateSetterFunction(PropertyId nameId, FunctionInfo* functionInfo);
579580

0 commit comments

Comments
 (0)