mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 23:20:20 +00:00
js: Don't try to run empty scripts
When you try to run script containing only whitespace, it will return undefined and doesn't do anything anyway. Let's match NodeJS behavior and just don't display anything. This only applies to REPL input and not to modules.
This commit is contained in:
parent
0706f0d487
commit
efd9c70d94
Notes:
sideshowbarker
2024-07-17 17:48:48 +09:00
Author: https://github.com/sppmacd Commit: https://github.com/SerenityOS/serenity/commit/efd9c70d94 Pull-request: https://github.com/SerenityOS/serenity/pull/12928 Reviewed-by: https://github.com/linusg
1 changed files with 3 additions and 1 deletions
|
@ -55,6 +55,7 @@
|
|||
#include <LibJS/Runtime/ShadowRealm.h>
|
||||
#include <LibJS/Runtime/Shape.h>
|
||||
#include <LibJS/Runtime/StringObject.h>
|
||||
#include <LibJS/Runtime/StringPrototype.h>
|
||||
#include <LibJS/Runtime/Temporal/Calendar.h>
|
||||
#include <LibJS/Runtime/Temporal/Duration.h>
|
||||
#include <LibJS/Runtime/Temporal/Instant.h>
|
||||
|
@ -1273,8 +1274,9 @@ static void repl(JS::Interpreter& interpreter)
|
|||
{
|
||||
while (!s_fail_repl) {
|
||||
String piece = read_next_piece();
|
||||
if (piece.is_empty())
|
||||
if (Utf8View { piece }.trim(JS::whitespace_characters).is_empty())
|
||||
continue;
|
||||
|
||||
repl_statements.append(piece);
|
||||
parse_and_run(interpreter, piece, "REPL");
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue