Commit 0edb1a99 authored by Masayuki Nakano's avatar Masayuki Nakano
Browse files

Bug 1748018 - Make `HTMLEditUtils::GetFirstListItemElement` scan only within...

Bug 1748018 - Make `HTMLEditUtils::GetFirstListItemElement` scan only within the given list element r=m_kato

It calls `nsINode::GetNextNode()` to scan first descendant list item in the
list without specifying the root node to scan within.  Therefore, it may return
following list item element of the given list element if the list element does
not have children.

Differential Revision: https://phabricator.services.mozilla.com/D135110
parent 88b259fb
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1341,7 +1341,7 @@ class HTMLEditUtils final {
    MOZ_ASSERT(HTMLEditUtils::IsAnyListElement(&aListElement));
    for (nsIContent* maybeFirstListItem = aListElement.GetFirstChild();
         maybeFirstListItem;
         maybeFirstListItem = maybeFirstListItem->GetNextNode()) {
         maybeFirstListItem = maybeFirstListItem->GetNextNode(&aListElement)) {
      if (HTMLEditUtils::IsListItem(maybeFirstListItem)) {
        return maybeFirstListItem->AsElement();
      }
+13 −0
Original line number Diff line number Diff line
<!DOCTYPE html>
<html id="a">
<meta charset="utf-8">
<script id="b">
window.onload = () => {
  c.appendChild(document.head)
  a.appendChild(d)
  document.execCommand("selectAll")
  document.execCommand("delete")
}
</script>
<dl id="c" contenteditable="true">
<dt id="d">