Skip to content

Commit

Permalink
Use early return
Browse files Browse the repository at this point in the history
  • Loading branch information
marvinhagemeister committed Apr 30, 2023
1 parent a537134 commit 4d2049e
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions debug/src/validateMarkup.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ function getClosestDomNodeParent(parent) {
export function validateTableMarkup(internal) {
const { type, _parent: parent } = internal;
const parentDomInternal = getClosestDomNodeParent(parent);
if (parentDomInternal === null) return;

if (
(type === 'thead' || type === 'tfoot' || type === 'tbody') &&
(parentDomInternal === null || parentDomInternal.type !== 'table')
parentDomInternal.type !== 'table'
) {
console.error(
'Improper nesting of table. Your <thead/tbody/tfoot> should have a <table> parent.' +
Expand All @@ -32,30 +33,23 @@ export function validateTableMarkup(internal) {
);
} else if (
type === 'tr' &&
(parentDomInternal === null ||
(parentDomInternal.type !== 'thead' &&
parentDomInternal.type !== 'tfoot' &&
parentDomInternal.type !== 'tbody' &&
parentDomInternal.type !== 'table'))
parentDomInternal.type !== 'thead' &&
parentDomInternal.type !== 'tfoot' &&
parentDomInternal.type !== 'tbody' &&
parentDomInternal.type !== 'table'
) {
console.error(
'Improper nesting of table. Your <tr> should have a <thead/tbody/tfoot/table> parent.' +
serializeVNode(internal) +
`\n\n${getOwnerStack(internal)}`
);
} else if (
type === 'td' &&
(parentDomInternal === null || parentDomInternal.type !== 'tr')
) {
} else if (type === 'td' && parentDomInternal.type !== 'tr') {
console.error(
'Improper nesting of table. Your <td> should have a <tr> parent.' +
serializeVNode(internal) +
`\n\n${getOwnerStack(internal)}`
);
} else if (
type === 'th' &&
(parentDomInternal === null || parentDomInternal.type !== 'tr')
) {
} else if (type === 'th' && parentDomInternal.type !== 'tr') {
console.error(
'Improper nesting of table. Your <th> should have a <tr>.' +
serializeVNode(internal) +
Expand Down

0 comments on commit 4d2049e

Please sign in to comment.