mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-03 04:52:06 +02:00
LibJS: Make parseFloat slightly more specification-compliant
This commit is contained in:
committed by
Linus Groh
parent
de2f5bb5a7
commit
27ca7bbbd7
Notes:
sideshowbarker
2024-07-17 20:42:21 +09:00
Author: https://github.com/IdanHo Commit: https://github.com/SerenityOS/serenity/commit/27ca7bbbd7f Pull-request: https://github.com/SerenityOS/serenity/pull/11950 Reviewed-by: https://github.com/alimpfard Reviewed-by: https://github.com/linusg
@@ -375,7 +375,7 @@ JS_DEFINE_NATIVE_FUNCTION(GlobalObject::parse_float)
|
||||
if (vm.argument(0).is_number())
|
||||
return vm.argument(0);
|
||||
auto input_string = TRY(vm.argument(0).to_string(global_object));
|
||||
auto trimmed_string = input_string.trim_whitespace(TrimMode::Left);
|
||||
auto trimmed_string = MUST(trim_string(global_object, js_string(vm, input_string), TrimMode::Left));
|
||||
for (size_t length = trimmed_string.length(); length > 0; --length) {
|
||||
auto number = MUST(Value(js_string(vm, trimmed_string.substring(0, length))).to_number(global_object));
|
||||
if (!number.is_nan())
|
||||
|
||||
Reference in New Issue
Block a user