| Index: src/js/string.js
|
| diff --git a/src/js/string.js b/src/js/string.js
|
| index c838064112f4543dda4e9dc2fb97c0b55d5f6bd3..0830059a522d5c76e28f51d739c433eff08c52cb 100644
|
| --- a/src/js/string.js
|
| +++ b/src/js/string.js
|
| @@ -23,6 +23,7 @@ var matchSymbol = utils.ImportNow("match_symbol");
|
| var RegExpExec;
|
| var RegExpExecNoTests;
|
| var RegExpLastMatchInfo;
|
| +var searchSymbol = utils.ImportNow("search_symbol");
|
| var splitSymbol = utils.ImportNow("split_symbol");
|
|
|
| utils.Import(function(from) {
|
| @@ -155,7 +156,7 @@ function StringLocaleCompareJS(other) {
|
| }
|
|
|
|
|
| -// ECMA-262 section 15.5.4.10
|
| +// ES6 21.1.3.11.
|
| function StringMatchJS(pattern) {
|
| CHECK_OBJECT_COERCIBLE(this, "String.prototype.match");
|
|
|
| @@ -505,21 +506,20 @@ function StringReplaceNonGlobalRegExpWithFunction(subject, regexp, replace) {
|
| }
|
|
|
|
|
| -// ECMA-262 section 15.5.4.12
|
| -function StringSearch(re) {
|
| +// ES6 21.1.3.15.
|
| +function StringSearch(pattern) {
|
| CHECK_OBJECT_COERCIBLE(this, "String.prototype.search");
|
|
|
| - var regexp;
|
| - if (IS_REGEXP(re)) {
|
| - regexp = re;
|
| - } else {
|
| - regexp = new GlobalRegExp(re);
|
| - }
|
| - var match = RegExpExec(regexp, TO_STRING(this), 0);
|
| - if (match) {
|
| - return match[CAPTURE0];
|
| + if (!IS_NULL_OR_UNDEFINED(pattern)) {
|
| + var searcher = pattern[searchSymbol];
|
| + if (!IS_UNDEFINED(searcher)) {
|
| + return %_Call(searcher, pattern, this);
|
| + }
|
| }
|
| - return -1;
|
| +
|
| + var subject = TO_STRING(this);
|
| + var regexp = new GlobalRegExp(pattern);
|
| + return %_Call(regexp[searchSymbol], regexp, subject);
|
| }
|
|
|
|
|
|
|