Skip to content

Commit

Permalink
Ensure all <tr> elements have tbody, thead or tfoot parents
Browse files Browse the repository at this point in the history
The latest Preact release warns about `<tr>` elements that have a `<table>` as
their direct parent. See preactjs/preact#4375.
  • Loading branch information
robertknight committed May 20, 2024
1 parent d00b812 commit 1ae0459
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 16 deletions.
20 changes: 12 additions & 8 deletions src/components/data/test/TableCell-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ describe('TableCell', () => {
return mount(
<TableContext.Provider value={tableContextValue}>
<table>
<TableSectionContext.Provider value={contextValue}>
<tr>
<TableCell {...props}>{props.children ?? 'Content'}</TableCell>
</tr>
</TableSectionContext.Provider>
<tbody>
<TableSectionContext.Provider value={contextValue}>
<tr>
<TableCell {...props}>{props.children ?? 'Content'}</TableCell>
</tr>
</TableSectionContext.Provider>
</tbody>
</table>
</TableContext.Provider>,
);
Expand All @@ -28,9 +30,11 @@ describe('TableCell', () => {
const contentFn = (Component, props = {}) => {
return mount(
<table>
<tr>
<Component {...props} />
</tr>
<tbody>
<tr>
<Component {...props} />
</tr>
</tbody>
</table>,
);
};
Expand Down
20 changes: 12 additions & 8 deletions src/components/data/test/TableRow-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ describe('TableRow', () => {
return mount(
<TableContext.Provider value={tableContextValue}>
<table>
<TableSectionContext.Provider value={sectionContextValue}>
<TableRow {...props}>
<td>Cell content</td>
</TableRow>
</TableSectionContext.Provider>
<tbody>
<TableSectionContext.Provider value={sectionContextValue}>
<TableRow {...props}>
<td>Cell content</td>
</TableRow>
</TableSectionContext.Provider>
</tbody>
</table>
</TableContext.Provider>,
);
Expand All @@ -28,9 +30,11 @@ describe('TableRow', () => {
const contentFn = (Component, props = {}) => {
return mount(
<table>
<Component {...props}>
<td>Cell content</td>
</Component>
<tbody>
<Component {...props}>
<td>Cell content</td>
</Component>
</tbody>
</table>,
);
};
Expand Down

0 comments on commit 1ae0459

Please sign in to comment.