Skip to content

Commit 16c7fb7

Browse files
authored
Fix debug check not firing when it has a parent (#4449)
1 parent a75b217 commit 16c7fb7

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

debug/src/debug.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ export function initDebug() {
370370
// `preact-render-to-string`. There we'd otherwise flood the terminal
371371
// with false positives, which we'd like to avoid.
372372
let domParentName = getClosestDomNodeParentName(parent);
373-
if (domParentName !== '') {
373+
if (domParentName !== '' && isTableElement(type)) {
374374
if (
375375
type === 'table' &&
376376
// Tables can be nested inside each other if it's inside a cell.

debug/test/browser/debug.test.js

+13
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,19 @@ describe('debug', () => {
662662
expect(console.error).to.be.calledOnce;
663663
});
664664

665+
it('should warn for nesting illegal dom-nodes under a paragraph with a parent', () => {
666+
const Paragraph = () => (
667+
<div>
668+
<p>
669+
<div>Hello world</div>
670+
</p>
671+
</div>
672+
);
673+
674+
render(<Paragraph />, scratch);
675+
expect(console.error).to.be.calledOnce;
676+
});
677+
665678
it('should warn for nesting illegal dom-nodes under a paragraph as func', () => {
666679
const Title = ({ children }) => <h1>{children}</h1>;
667680
const Paragraph = () => (

0 commit comments

Comments
 (0)