Chromium Code Reviews| Index: src/harmony-array.js |
| diff --git a/src/harmony-array.js b/src/harmony-array.js |
| index b24caff9a9f3cd1129d264cf3f7581ad40a39056..62ee802b3687f9af59c7a625296552af69cd63c0 100644 |
| --- a/src/harmony-array.js |
| +++ b/src/harmony-array.js |
| @@ -83,9 +83,9 @@ function ArrayFind(predicate /* thisArg */) { // length == 1 |
| } |
| var needs_wrapper = false; |
| - if (IS_NULL_OR_UNDEFINED(thisArg)) { |
| - thisArg = %GetDefaultReceiver(predicate) || thisArg; |
| - } else { |
| + if (IS_NULL(thisArg)) { |
| + if (%IsSloppyModeFunction(predicate)) thisArg = UNDEFINED; |
| + } else if (!IS_UNDEFINED(thisArg)) { |
| needs_wrapper = SHOULD_CREATE_WRAPPER(predicate, thisArg); |
| } |
| @@ -120,9 +120,9 @@ function ArrayFindIndex(predicate /* thisArg */) { // length == 1 |
| } |
| var needs_wrapper = false; |
| - if (IS_NULL_OR_UNDEFINED(thisArg)) { |
| - thisArg = %GetDefaultReceiver(predicate) || thisArg; |
| - } else { |
| + if (IS_NULL(thisArg)) { |
| + if (%IsSloppyModeFunction(predicate)) thisArg = UNDEFINED; |
| + } else if (!IS_UNDEFINED(thisArg)) { |
| needs_wrapper = SHOULD_CREATE_WRAPPER(predicate, thisArg); |
| } |
| @@ -190,10 +190,12 @@ function ArrayFrom(arrayLike, mapfn, receiver) { |
| if (mapping) { |
| if (!IS_SPEC_FUNCTION(mapfn)) { |
| throw MakeTypeError(kCalledNonCallable, mapfn); |
| - } else if (IS_NULL_OR_UNDEFINED(receiver)) { |
| - receiver = %GetDefaultReceiver(mapfn) || receiver; |
| - } else if (!IS_SPEC_OBJECT(receiver) && %IsSloppyModeFunction(mapfn)) { |
| - receiver = ToObject(receiver); |
| + } else if (%IsSloppyModeFunction(mapfn)) { |
| + if (IS_NULL(receiver)) { |
| + receiver = UNDEFINED; |
| + } else if (!IS_UNDEFINED(receiver) && !IS_SPEC_OBJECT(receiver)) { |
| + receiver = SHOULD_CREATE_WRAPPER(mapfn, receiver); |
|
rossberg
2015/05/04 11:00:17
ToObject
|
| + } |
| } |
| } |