mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-25 17:25:08 +02:00
LibJS: Avoid Symbol methods for RegExp on primitives
Normative PR: https://github.com/tc39/ecma262/pull/3009 (unmerged as of this commit) There are a few test262 tests for this, see https://test262.fyi/#built-ins/String/prototype JSC and Rhino have have already added these changes.
This commit is contained in:
committed by
Andrew Kaster
parent
d4a5d16d27
commit
1861f24979
Notes:
github-actions[bot]
2025-06-17 23:55:53 +00:00
Author: https://github.com/sno2 Commit: https://github.com/LadybirdBrowser/ladybird/commit/1861f24979f Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4619 Reviewed-by: https://github.com/ADKaster ✅
@@ -564,9 +564,9 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::match)
|
||||
// 1. Let O be ? RequireObjectCoercible(this value).
|
||||
auto this_object = TRY(require_object_coercible(vm, vm.this_value()));
|
||||
|
||||
// 2. If regexp is neither undefined nor null, then
|
||||
// 2. If regexp is an Object, then
|
||||
auto regexp = vm.argument(0);
|
||||
if (!regexp.is_nullish()) {
|
||||
if (regexp.is_object()) {
|
||||
// a. Let matcher be ? GetMethod(regexp, @@match).
|
||||
auto matcher = TRY(regexp.get_method(vm, vm.well_known_symbol_match()));
|
||||
|
||||
@@ -595,8 +595,8 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::match_all)
|
||||
// 1. Let O be ? RequireObjectCoercible(this value).
|
||||
auto this_object = TRY(require_object_coercible(vm, vm.this_value()));
|
||||
|
||||
// 2. If regexp is neither undefined nor null, then
|
||||
if (!regexp.is_nullish()) {
|
||||
// 2. If regexp is an Object, then
|
||||
if (regexp.is_object()) {
|
||||
// a. Let isRegExp be ? IsRegExp(regexp).
|
||||
auto is_regexp = TRY(regexp.is_regexp(vm));
|
||||
|
||||
@@ -782,8 +782,8 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::replace)
|
||||
// 1. Let O be ? RequireObjectCoercible(this value).
|
||||
auto this_object = TRY(require_object_coercible(vm, vm.this_value()));
|
||||
|
||||
// 2. If searchValue is neither undefined nor null, then
|
||||
if (!search_value.is_nullish()) {
|
||||
// 2. If searchValue is an Object, then
|
||||
if (search_value.is_object()) {
|
||||
// a. Let replacer be ? GetMethod(searchValue, @@replace).
|
||||
auto replacer = TRY(search_value.get_method(vm, vm.well_known_symbol_replace()));
|
||||
|
||||
@@ -861,8 +861,8 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::replace_all)
|
||||
// 1. Let O be ? RequireObjectCoercible(this value).
|
||||
auto this_object = TRY(require_object_coercible(vm, vm.this_value()));
|
||||
|
||||
// 2. If searchValue is neither undefined nor null, then
|
||||
if (!search_value.is_nullish()) {
|
||||
// 2. If searchValue is an Object, then
|
||||
if (search_value.is_object()) {
|
||||
// a. Let isRegExp be ? IsRegExp(searchValue).
|
||||
bool is_regexp = TRY(search_value.is_regexp(vm));
|
||||
|
||||
@@ -977,8 +977,8 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::search)
|
||||
// 1. Let O be ? RequireObjectCoercible(this value).
|
||||
auto this_object = TRY(require_object_coercible(vm, vm.this_value()));
|
||||
|
||||
// 2. If regexp is neither undefined nor null, then
|
||||
if (!regexp.is_nullish()) {
|
||||
// 2. If regexp is an Object, then
|
||||
if (regexp.is_object()) {
|
||||
// a. Let searcher be ? GetMethod(regexp, @@search).
|
||||
auto searcher = TRY(regexp.get_method(vm, vm.well_known_symbol_search()));
|
||||
|
||||
@@ -1058,8 +1058,8 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::split)
|
||||
// 1. Let O be ? RequireObjectCoercible(this value).
|
||||
auto object = TRY(require_object_coercible(vm, vm.this_value()));
|
||||
|
||||
// 2. If separator is neither undefined nor null, then
|
||||
if (!separator_argument.is_nullish()) {
|
||||
// 2. If separator is an Object, then
|
||||
if (separator_argument.is_object()) {
|
||||
// a. Let splitter be ? GetMethod(separator, @@split).
|
||||
auto splitter = TRY(separator_argument.get_method(vm, vm.well_known_symbol_split()));
|
||||
// b. If splitter is not undefined, then
|
||||
|
||||
Reference in New Issue
Block a user