Skip to content

Commit

Permalink
es5-shim.js: fix issue es-shims#412
Browse files Browse the repository at this point in the history
Pass arguments to the original function
  • Loading branch information
Yegor committed Oct 21, 2016
1 parent b291cfa commit 8bab708
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions es5-shim.js
Original file line number Diff line number Diff line change
Expand Up @@ -1885,13 +1885,13 @@
if (!isFn || !hasCapturingGroups) {
return str_replace.call(this, searchValue, replaceValue);
} else {
var wrappedReplaceValue = function (match) {
var length = arguments.length;
var originalLastIndex = searchValue.lastIndex;
searchValue.lastIndex = 0;
var args = searchValue.exec(match) || [];
searchValue.lastIndex = originalLastIndex;
pushCall(args, arguments[length - 2], arguments[length - 1]);
var wrappedReplaceValue = function () {
var args = [];

for (var i = 0; i < arguments.length; i++) {
args[i] = arguments[i] === '' ? undefined : arguments[i];
}

return replaceValue.apply(this, args);
};
return str_replace.call(this, searchValue, wrappedReplaceValue);
Expand Down

0 comments on commit 8bab708

Please sign in to comment.