opens", () => {
+ const onopentagname = vi.fn();
+ const onclosetag = vi.fn();
+
+ new Parser({ onopentagname, onclosetag }).end(
+ "",
+ );
+
+ expect(onclosetag).toHaveBeenCalledWith("tbody", true);
+ const tbodyClose = onclosetag.mock.calls.findIndex(
+ ([name]) => name === "tbody",
+ );
+ const theadOpen = onopentagname.mock.calls.findIndex(
+ ([name]) => name === "thead",
+ );
+ expect(tbodyClose).toBeLessThan(theadOpen);
+ });
+
it("should implicitly close | when | opens", () => {
const onclosetag = vi.fn();
const onopentagname = vi.fn();
@@ -190,10 +227,10 @@ describe("API", () => {
// | must auto-close | , making them siblings per the HTML spec
expect(onclosetag).toHaveBeenCalledWith("td", true);
const tdClose = onclosetag.mock.calls.findIndex(
- ([name]: [string]) => name === "td",
+ ([name]) => name === "td",
);
const thOpen = onopentagname.mock.calls.findIndex(
- ([name]: [string]) => name === "th",
+ ([name]) => name === "th",
);
expect(tdClose).toBeLessThan(thOpen);
});
diff --git a/src/Parser.ts b/src/Parser.ts
index 875058dd..33050243 100644
--- a/src/Parser.ts
+++ b/src/Parser.ts
@@ -13,7 +13,7 @@ const formTags = new Set([
]);
const pTag = new Set(["p"]);
const headingTags = new Set(["h1", "h2", "h3", "h4", "h5", "h6", "p"]);
-const tableSectionTags = new Set(["thead", "tbody"]);
+const tableSectionTags = new Set(["thead", "tbody", "tfoot", "tr", "td", "th"]);
const ddtTags = new Set(["dd", "dt"]);
const rtpTags = new Set(["rt", "rp"]);
@@ -64,6 +64,7 @@ const openImpliesClose = new Map>([
["ul", pTag],
["rt", rtpTags],
["rp", rtpTags],
+ ["thead", tableSectionTags],
["tbody", tableSectionTags],
["tfoot", tableSectionTags],
]);
|