Ignore:
Timestamp:
Nov 21, 2019, 3:35:21 PM (5 years ago)
Author:
[email protected]
Message:

Unreviewed, rolling in again, regression is not caused by it
https://bugs.webkit.org/show_bug.cgi?id=202471

JSTests:

  • stress/string-replaceall.js: Added.

(shouldBe):
(shouldThrowTypeError):
(shouldBe.string_appeared_here.replaceAll.Symbol.match):

Source/JavaScriptCore:

  • builtins/BuiltinNames.h:
  • builtins/StringPrototype.js:

(replaceAll):

  • runtime/StringPrototype.cpp:

(JSC::StringPrototype::finishCreation):
(JSC::jsSpliceSubstringsWithSeparators):
(JSC::replaceUsingStringSearch):
(JSC::replace):
(JSC::stringProtoFuncReplaceUsingStringSearch):
(JSC::stringProtoFuncReplaceAllUsingStringSearch):

Source/WTF:

  • wtf/text/StringCommon.h:

(WTF::findCommon):

LayoutTests:

  • js/Object-getOwnPropertyNames-expected.txt:
  • js/script-tests/Object-getOwnPropertyNames.js:
Location:
trunk/Source/JavaScriptCore/builtins
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/builtins/BuiltinNames.h

    r252753 r252754  
    133133    macro(replaceUsingRegExp) \
    134134    macro(replaceUsingStringSearch) \
     135    macro(replaceAllUsingStringSearch) \
    135136    macro(makeTypeError) \
    136137    macro(mapBucket) \
  • trunk/Source/JavaScriptCore/builtins/StringPrototype.js

    r252753 r252754  
    260260}
    261261
     262function replaceAll(search, replace)
     263{
     264    "use strict";
     265
     266    if (@isUndefinedOrNull(this))
     267        @throwTypeError("String.prototype.replaceAll requires |this| not to be null nor undefined");
     268
     269    if (search != null) {
     270        if (@isRegExp(search) && !@stringIncludesInternal.@call(@toString(search.flags), "g"))
     271            @throwTypeError("String.prototype.replaceAll argument must not be a non-global regular expression");
     272
     273        var replacer = search.@replaceSymbol;
     274        if (replacer !== @undefined) {
     275            if (!@hasObservableSideEffectsForStringReplace(search, replacer))
     276                return @toString(this).@replaceUsingRegExp(search, replace);
     277            return replacer.@call(search, this, replace);
     278        }
     279    }
     280
     281    var thisString = @toString(this);
     282    var searchString = @toString(search);
     283    return thisString.@replaceAllUsingStringSearch(searchString, replace);
     284}
     285
    262286function search(regexp)
    263287{
Note: See TracChangeset for help on using the changeset viewer.