mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-04 07:36:50 +00:00
LibWeb: Correct logic for removing end nodes from HTMLOptionsCollection
This test case would previously crash. Found with domato.
This commit is contained in:
committed by
Tim Ledbetter
parent
f61e54b10c
commit
0cec68ea99
@@ -0,0 +1,3 @@
|
|||||||
|
0
|
||||||
|
1
|
||||||
|
0
|
||||||
12
Tests/LibWeb/Text/input/DOM/HTMLSelectElement-length.html
Normal file
12
Tests/LibWeb/Text/input/DOM/HTMLSelectElement-length.html
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<script src="../include.js"></script>
|
||||||
|
<script>
|
||||||
|
test(() => {
|
||||||
|
const select = document.createElement("select");
|
||||||
|
const option = document.createElement("option");
|
||||||
|
println(select.length);
|
||||||
|
select.add(option);
|
||||||
|
println(select.length);
|
||||||
|
select.length = 0;
|
||||||
|
println(select.length);
|
||||||
|
});
|
||||||
|
</script>
|
||||||
@@ -66,8 +66,8 @@ WebIDL::ExceptionOr<void> HTMLOptionsCollection::set_length(WebIDL::UnsignedLong
|
|||||||
auto n = current - value;
|
auto n = current - value;
|
||||||
|
|
||||||
// 3.2. Remove the last n nodes in the collection from their parent nodes.
|
// 3.2. Remove the last n nodes in the collection from their parent nodes.
|
||||||
for (WebIDL::UnsignedLong i = current - 1; i >= current - n; i--)
|
for (auto i = 0u; i < n; i++)
|
||||||
this->item(i)->remove();
|
item(length() - 1)->remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
|
|||||||
Reference in New Issue
Block a user