Skip to content

Commit

Permalink
add validation for th/thead/tbody and skip validation of empty tabl…
Browse files Browse the repository at this point in the history
…e components
  • Loading branch information
titoBouzout committed Oct 2, 2024
1 parent d3b212b commit 0b6f3a1
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 @@ -46,7 +46,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
Element.innerHTML = html;
Expand Down

0 comments on commit 0b6f3a1

Please sign in to comment.