| Index: src/string.js
|
| diff --git a/src/string.js b/src/string.js
|
| index a3e3e0991ba10730adc4769d32ec5a7fd09e074e..297105d0474fa73d1653f9ffbc582b49c45a6624 100644
|
| --- a/src/string.js
|
| +++ b/src/string.js
|
| @@ -440,13 +440,14 @@ function StringReplaceGlobalRegExpWithFunction(subject, regexp, replace) {
|
| i++;
|
| }
|
| } else {
|
| + var receiver = %GetDefaultReceiver(replace);
|
| while (i < len) {
|
| var elem = res[i];
|
| if (!%_IsSmi(elem)) {
|
| // elem must be an Array.
|
| // Use the apply argument as backing for global RegExp properties.
|
| lastMatchInfoOverride = elem;
|
| - var func_result = replace.apply(null, elem);
|
| + var func_result = %Apply(replace, receiver, elem, 0, elem.length);
|
| res[i] = TO_STRING_INLINE(func_result);
|
| }
|
| i++;
|
| @@ -472,11 +473,11 @@ function StringReplaceNonGlobalRegExpWithFunction(subject, regexp, replace) {
|
| // The number of captures plus one for the match.
|
| var m = NUMBER_OF_CAPTURES(matchInfo) >> 1;
|
| var replacement;
|
| + var receiver = %GetDefaultReceiver(replace);
|
| if (m == 1) {
|
| // No captures, only the match, which is always valid.
|
| var s = SubString(subject, index, endOfMatch);
|
| // Don't call directly to avoid exposing the built-in global object.
|
| - var receiver = %GetDefaultReceiver(replace);
|
| replacement =
|
| %_CallFunction(receiver, s, index, subject, replace);
|
| } else {
|
| @@ -487,7 +488,7 @@ function StringReplaceNonGlobalRegExpWithFunction(subject, regexp, replace) {
|
| parameters[j] = index;
|
| parameters[j + 1] = subject;
|
|
|
| - replacement = replace.apply(null, parameters);
|
| + replacement = %Apply(replace, receiver, parameters, 0, j + 2);
|
| }
|
|
|
| result.add(replacement); // The add method converts to string if necessary.
|
|
|