Skip to content

Commit

Permalink
Merge pull request #360 from titoBouzout/validationtableedgecase
Browse files Browse the repository at this point in the history
Update special cases for tables
  • Loading branch information
ryansolid authored Oct 7, 2024
2 parents fc5fdb7 + 960c554 commit 2415f6b
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion packages/babel-plugin-jsx-dom-expressions/src/shared/validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,25 @@ export function isInvalidMarkup(html) {
.replace(/<\/tr>$/i, "</tr></tbody></table>")
// fix tables cells
.replace(/^<td>/i, "<table><tbody><tr><td>")
.replace(/<\/td>$/i, "</td></tr></tbody></table>");
.replace(/<\/td>$/i, "</td></tr></tbody></table>")
.replace(/^<th>/i, "<table><thead><tr><th>")
.replace(/<\/th>$/i, "</th></tr></thead></table>")
// fix table components
.replace(/^<thead>/i, "<table><thead>")
.replace(/<\/thead>$/i, "</thead></table>")
.replace(/^<tbody>/i, "<table><tbody>")
.replace(/<\/tbody>$/i, "</tbody></table>");

// skip when equal to:
switch (html) {
// empty table components
case "<table></table>":
case "<table><thead></thead></table>":
case "<table><tbody></tbody></table>":
case "<table><thead></thead><tbody></tbody></table>": {
return;
}
}

/** Parse HTML. `browser` is a string with the supposed resulting html of a real `innerHTML` call */
const browser = innerHTML(html);
Expand Down

0 comments on commit 2415f6b

Please sign in to comment.