mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 07:17:35 +00:00
LibJS: Replace strings with the search value coerced to a string
This only causes 1 new test262 test to pass. Other tests that rely on this coercion fail due to receiving an unexpected value for 'this' when invoking a functional replacement. For example: String/prototype/replaceAll/replaceValue-call-matching-empty.js Receives 'undefined' for 'this' in the functional replacement invocation but is expected to receive the global 'this'.
This commit is contained in:
parent
81fec49ac3
commit
e0d26fff8c
3 changed files with 44 additions and 2 deletions
|
@ -819,7 +819,7 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::replace)
|
|||
String replacement;
|
||||
|
||||
if (replace_value.is_function()) {
|
||||
auto result = vm.call(replace_value.as_function(), js_undefined(), search_value, Value(position.value()), js_string(vm, string));
|
||||
auto result = vm.call(replace_value.as_function(), js_undefined(), js_string(vm, search_string), Value(position.value()), js_string(vm, string));
|
||||
if (vm.exception())
|
||||
return {};
|
||||
|
||||
|
@ -915,7 +915,7 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::replace_all)
|
|||
String replacement;
|
||||
|
||||
if (replace_value.is_function()) {
|
||||
auto result = vm.call(replace_value.as_function(), js_undefined(), search_value, Value(position), js_string(vm, string));
|
||||
auto result = vm.call(replace_value.as_function(), js_undefined(), js_string(vm, search_string), Value(position), js_string(vm, string));
|
||||
if (vm.exception())
|
||||
return {};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue