Skip to content

Commit

Permalink
LibJS: Make String.prototype.slice() generic
Browse files Browse the repository at this point in the history
  • Loading branch information
linusg authored and awesomekling committed Apr 29, 2020
1 parent cfdb7b8 commit 8159f45
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
6 changes: 2 additions & 4 deletions Libraries/LibJS/Runtime/StringPrototype.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ try {
"concat",
"substring",
"includes",
"slice",
];

genericStringPrototypeFunctions.forEach(name => {
Expand Down

0 comments on commit 8159f45

Please sign in to comment.