summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIdan Horowitz <idan.horowitz@gmail.com>2022-03-12 23:48:05 +0200
committerAndreas Kling <kling@serenityos.org>2022-03-12 23:49:50 +0100
commit57090f75ae45c8980583b3eef420228e318d3d90 (patch)
tree712272330a38eda7de9bf459367d9d0153d552bd
parentfe3b846ac825d8d91923cb1407dcecf66f29513e (diff)
downloadserenity-57090f75ae45c8980583b3eef420228e318d3d90.zip
LibWeb: Correct invalid index check in HTMLTableElement::insertRow()
As well as change the matching error message in deleteRow(), which likely caused this mistake in the first place.
-rw-r--r--Userland/Libraries/LibWeb/HTML/HTMLTableElement.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTableElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLTableElement.cpp
index cbb0045b86..d9a161ad25 100644
--- a/Userland/Libraries/LibWeb/HTML/HTMLTableElement.cpp
+++ b/Userland/Libraries/LibWeb/HTML/HTMLTableElement.cpp
@@ -284,7 +284,7 @@ DOM::ExceptionOr<NonnullRefPtr<HTMLTableRowElement>> HTMLTableElement::insert_ro
auto rows = this->rows();
auto rows_length = rows->length();
- if (index < -1 || index >= (long)rows_length) {
+ if (index < -1 || index > (long)rows_length) {
return DOM::IndexSizeError::create("Index is negative or greater than the number of rows");
}
auto tr = static_ptr_cast<HTMLTableRowElement>(DOM::create_element(document(), TagNames::tr, Namespace::HTML));
@@ -312,7 +312,7 @@ DOM::ExceptionOr<void> HTMLTableElement::delete_row(long index)
// 1. If index is less than −1 or greater than or equal to the number of elements in the rows collection, then throw an "IndexSizeError" DOMException.
if (index < -1 || index >= (long)rows_length)
- return DOM::IndexSizeError::create("Index is negative or greater than the number of rows");
+ return DOM::IndexSizeError::create("Index is negative or greater than or equal to the number of rows");
// 2. If index is −1, then remove the last element in the rows collection from its parent, or do nothing if the rows collection is empty.
if (index == -1) {