diff options
author | Linus Groh <mail@linusgroh.de> | 2020-04-29 18:06:36 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-04-29 19:14:36 +0200 |
commit | 8159f45f6ee1ddc551df82a2102f6bc9bc9059af (patch) | |
tree | e762cfdeb2f598e150e02ac80be74d58dbd03be7 | |
parent | cfdb7b8806da36520f2b43fb979b9bdadd09a73a (diff) | |
download | serenity-8159f45f6ee1ddc551df82a2102f6bc9bc9059af.zip |
LibJS: Make String.prototype.slice() generic
-rw-r--r-- | Libraries/LibJS/Runtime/StringPrototype.cpp | 6 | ||||
-rw-r--r-- | Libraries/LibJS/Tests/String.prototype-generic-functions.js | 1 |
2 files changed, 3 insertions, 4 deletions
diff --git a/Libraries/LibJS/Runtime/StringPrototype.cpp b/Libraries/LibJS/Runtime/StringPrototype.cpp index fda0f2cce6..6fe439fe0b 100644 --- a/Libraries/LibJS/Runtime/StringPrototype.cpp +++ b/Libraries/LibJS/Runtime/StringPrototype.cpp @@ -388,12 +388,10 @@ Value StringPrototype::includes(Interpreter& interpreter) Value StringPrototype::slice(Interpreter& interpreter) { - auto* string_object = string_object_from(interpreter); - if (!string_object) + auto string = string_from(interpreter); + if (string.is_null()) return {}; - auto& string = string_object->primitive_string().string(); - if (interpreter.argument_count() == 0) return js_string(interpreter, string); diff --git a/Libraries/LibJS/Tests/String.prototype-generic-functions.js b/Libraries/LibJS/Tests/String.prototype-generic-functions.js index 776fb208dd..2975f84a9c 100644 --- a/Libraries/LibJS/Tests/String.prototype-generic-functions.js +++ b/Libraries/LibJS/Tests/String.prototype-generic-functions.js @@ -16,6 +16,7 @@ try { "concat", "substring", "includes", + "slice", ]; genericStringPrototypeFunctions.forEach(name => { |