Skip to content

Commit

Permalink
Fix debug check not firing when it has a parent
Browse files Browse the repository at this point in the history
  • Loading branch information
JoviDeCroock committed Jul 19, 2024
1 parent a75b217 commit 0cdc8d2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion debug/src/debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ export function initDebug() {
// `preact-render-to-string`. There we'd otherwise flood the terminal
// with false positives, which we'd like to avoid.
let domParentName = getClosestDomNodeParentName(parent);
if (domParentName !== '') {
if (domParentName !== '' && isTableElement(type)) {
if (
type === 'table' &&
// Tables can be nested inside each other if it's inside a cell.
Expand Down
13 changes: 13 additions & 0 deletions debug/test/browser/debug.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,19 @@ describe('debug', () => {
expect(console.error).to.be.calledOnce;
});

it('should warn for nesting illegal dom-nodes under a paragraph with a parent', () => {
const Paragraph = () => (
<div>
<p>
<div>Hello world</div>
</p>
</div>
);

render(<Paragraph />, scratch);
expect(console.error).to.be.calledOnce;
});

it('should warn for nesting illegal dom-nodes under a paragraph as func', () => {
const Title = ({ children }) => <h1>{children}</h1>;
const Paragraph = () => (
Expand Down

0 comments on commit 0cdc8d2

Please sign in to comment.