mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 13:37:44 +00:00
LibJS: Implement RegExp.prototype [ @@search ] with UTF-16 code units
This commit is contained in:
parent
2c023157e9
commit
66c31a0c07
3 changed files with 21 additions and 13 deletions
|
@ -787,14 +787,14 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::symbol_replace)
|
|||
// 22.2.5.11 RegExp.prototype [ @@search ] ( string ), https://tc39.es/ecma262/#sec-regexp.prototype-@@search
|
||||
JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::symbol_search)
|
||||
{
|
||||
auto string_value = vm.argument(0);
|
||||
|
||||
auto* regexp_object = this_object_from(vm, global_object);
|
||||
if (!regexp_object)
|
||||
return {};
|
||||
auto string = string_value.to_string(global_object);
|
||||
|
||||
auto string = vm.argument(0).to_utf16_string(global_object);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
Utf16View string_view { string };
|
||||
|
||||
auto previous_last_index = regexp_object->get(vm.names.lastIndex);
|
||||
if (vm.exception())
|
||||
|
@ -805,7 +805,7 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::symbol_search)
|
|||
return {};
|
||||
}
|
||||
|
||||
auto result = regexp_exec(global_object, *regexp_object, string);
|
||||
auto result = regexp_exec(global_object, *regexp_object, string_view);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
|
||||
|
|
|
@ -1085,13 +1085,16 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::search)
|
|||
if (vm.exception())
|
||||
return {};
|
||||
}
|
||||
auto s = this_object.to_string(global_object);
|
||||
|
||||
auto string = this_object.to_utf16_string(global_object);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
Utf16View utf16_string_view { string };
|
||||
|
||||
auto rx = regexp_create(global_object, regexp, js_undefined());
|
||||
if (!rx)
|
||||
return {};
|
||||
return rx->invoke(*vm.well_known_symbol_search(), js_string(vm, s));
|
||||
return rx->invoke(*vm.well_known_symbol_search(), js_string(vm, utf16_string_view));
|
||||
}
|
||||
|
||||
// B.2.3.2.1 CreateHTML ( string, tag, attribute, value ), https://tc39.es/ecma262/#sec-createhtml
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue