Skip to content

Commit 55b0dbc

Browse files
committed
Array.from should work with proxy
1 parent c3fd65f commit 55b0dbc

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

lib/Runtime/Library/JavascriptArray.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10337,17 +10337,17 @@ using namespace Js;
1033710337
SETOBJECT_FOR_MUTATION(jsReentLock, itemsArr);
1033810338

1033910339
bool mapping = false;
10340-
JavascriptFunction* mapFn = nullptr;
10340+
RecyclableObject* mapFn = nullptr;
1034110341
Var mapFnThisArg = nullptr;
1034210342

1034310343
if (args.Info.Count >= 3 && !JavascriptOperators::IsUndefinedObject(args[2]))
1034410344
{
10345-
if (!VarIs<JavascriptFunction>(args[2]))
10345+
if (!JavascriptConversion::IsCallable(args[2]))
1034610346
{
1034710347
JavascriptError::ThrowTypeError(scriptContext, JSERR_FunctionArgument_NeedFunction, _u("Array.from"));
1034810348
}
1034910349

10350-
mapFn = VarTo<JavascriptFunction>(args[2]);
10350+
mapFn = VarTo<RecyclableObject>(args[2]);
1035110351

1035210352
if (args.Info.Count >= 4)
1035310353
{

test/es6/ES6ArrayAPI.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ var tests = [
101101
assert.areEqual([0,1,2], fromFnc.call(null, [0,1,2]), "Calling Array.from with null this argument produces an array");
102102
assert.areEqual([0,1,2], fromFnc.call({}, [0,1,2]), "Calling Array.from with a non-function this argument produces an array");
103103
assert.areEqual([0,1,2], fromFnc.call(Math.sin, [0,1,2]), "Calling Array.from with a non-constructor function this argument produces an array");
104+
assert.areEqual([2], Array.from([1], new Proxy(() => 2, {})), "Calling Array.from with a proxy calls the proxy");
104105
}
105106
},
106107
{

0 commit comments

Comments
 (0)