зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1499571 - HTMLOptionsCollection::Remove shouldn't remove the first element of the collection if out of bounds. r=bzbarsky
Make it just forward to HTMLSelectElement::Remove like other browsers. Differential Revision: https://phabricator.services.mozilla.com/D8934 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
0576d8d43c
Коммит
fc1a493642
|
@ -285,11 +285,6 @@ HTMLOptionsCollection::Remove(int32_t aIndex, ErrorResult& aError)
|
|||
aError.Throw(NS_ERROR_UNEXPECTED);
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t len = mSelect->Length();
|
||||
if (aIndex < 0 || (uint32_t)aIndex >= len)
|
||||
aIndex = 0;
|
||||
|
||||
mSelect->Remove(aIndex);
|
||||
}
|
||||
|
||||
|
|
|
@ -600,6 +600,10 @@ HTMLSelectElement::Add(nsGenericHTMLElement& aElement,
|
|||
void
|
||||
HTMLSelectElement::Remove(int32_t aIndex)
|
||||
{
|
||||
if (aIndex < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsINode> option = Item(static_cast<uint32_t>(aIndex));
|
||||
if (!option) {
|
||||
return;
|
||||
|
|
|
@ -27,8 +27,8 @@ sel.appendChild(opt);
|
|||
sel.options.remove(0);
|
||||
sel.options.remove(1000);
|
||||
sel.options.remove(-1);
|
||||
is(sel.length, 1, "Unexpected option collection length");
|
||||
is(sel[0].value, "10", "Unexpected remained option");
|
||||
is(sel.length, 3, "Unexpected option collection length");
|
||||
is(sel[2].value, "10", "Unexpected remained option");
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
[select-remove.html]
|
||||
[select.options.remove(n) should work]
|
||||
expected: FAIL
|
||||
|
Загрузка…
Ссылка в новой задаче