help-beta: Flatten only in case of matching tagName.

In the commits following this, we are going to make changes which will
introduce cases with paragraphs, code blocks and other elements inside
list items. Right now, FlattenList will just break in those cases. We
need to return those elements without flattening since those are valid
elements inside a list item.
This commit is contained in:
Shubham Padia
2025-07-28 13:47:28 +00:00
committed by Tim Abbott
parent 8d0f67c3d5
commit 429bbae77c

View File

@@ -26,12 +26,15 @@ const flattened = {
if (other.type === "comment") {
return [];
}
assert.ok(
other.type === "element" &&
(other.tagName === first_element.tagName ||
other.tagName === "aside"),
);
return other.children;
assert.ok(other.type === "element");
// Flatten only in case of matching tagName, for the rest, we
// return the elements without flattening since asides, code
// blocks and other elements can be part of a single list item
// and we do not want to flatten them.
if (other.tagName === first_element.tagName) {
return other.children;
}
return [other];
}),
};
---