From 0cdc8d2887b156100c09d9468d4e13552922736c Mon Sep 17 00:00:00 2001 From: jdecroock Date: Fri, 19 Jul 2024 09:44:05 +0200 Subject: [PATCH] Fix debug check not firing when it has a parent --- debug/src/debug.js | 2 +- debug/test/browser/debug.test.js | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/debug/src/debug.js b/debug/src/debug.js index fab1d7915b..e51719e7c8 100644 --- a/debug/src/debug.js +++ b/debug/src/debug.js @@ -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. diff --git a/debug/test/browser/debug.test.js b/debug/test/browser/debug.test.js index e435d5cb50..2dcb5a05ae 100644 --- a/debug/test/browser/debug.test.js +++ b/debug/test/browser/debug.test.js @@ -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 = () => ( +
+

+

Hello world
+

+
+ ); + + render(, scratch); + expect(console.error).to.be.calledOnce; + }); + it('should warn for nesting illegal dom-nodes under a paragraph as func', () => { const Title = ({ children }) =>

{children}

; const Paragraph = () => (