From 32a60dbcaad2afd48eca4612e098c7b4c1eb3f5b Mon Sep 17 00:00:00 2001 From: Ryan Christian Date: Wed, 8 May 2024 19:41:42 -0500 Subject: [PATCH 1/3] feat: Provide error log for nesting of ; + + render( + + ); + + render(; + const Button = () => ( + + ); + + render( + ); + + render( + + ); + + render(, scratch); + expect(console.error).to.not.be.called; + }); + }); + describe('PropTypes', () => { beforeEach(() => { resetPropWarnings(); From 8a45c302c1b71408bb2b570a7ab526b7d943e1ac Mon Sep 17 00:00:00 2001 From: Ryan Christian Date: Wed, 8 May 2024 19:44:49 -0500 Subject: [PATCH 2/3] chore: Better formatting --- debug/src/debug.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/debug/src/debug.js b/debug/src/debug.js index d0f6e35c29..b69c916e53 100644 --- a/debug/src/debug.js +++ b/debug/src/debug.js @@ -430,11 +430,8 @@ export function initDebug() { } else if (type === 'a' || type === 'button') { if (getDomChildren(vnode).find(childType => childType === type)) { console.error( - 'Improper nesting of interactive content. Your <' + - type + - '> should not have ' + - 'other ' + - (type === 'a' ? 'anchor' : 'button') + + `Improper nesting of interactive content. Your <${type}>` + + ` should not have other ${type === 'a' ? 'anchor' : 'button'}` + ' tags as child-elements.' + serializeVNode(vnode) + `\n\n${getOwnerStack(vnode)}` From a51c8e24ef836345c5525d6ab0c1a5949162f46e Mon Sep 17 00:00:00 2001 From: Ryan Christian Date: Wed, 8 May 2024 19:49:00 -0500 Subject: [PATCH 3/3] refactor: Swap `.find()` for `.indexOf()` --- debug/src/debug.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debug/src/debug.js b/debug/src/debug.js index b69c916e53..1e47631ed9 100644 --- a/debug/src/debug.js +++ b/debug/src/debug.js @@ -428,7 +428,7 @@ export function initDebug() { ); } } else if (type === 'a' || type === 'button') { - if (getDomChildren(vnode).find(childType => childType === type)) { + if (getDomChildren(vnode).indexOf(type) !== -1) { console.error( `Improper nesting of interactive content. Your <${type}>` + ` should not have other ${type === 'a' ? 'anchor' : 'button'}` +