isTagValidWithParent() — react Function Reference
Architecture documentation for the isTagValidWithParent() function in validateDOMNesting.js from the react codebase.
Entity Profile
Dependency Diagram
graph TD af0fc495_4d30_0fb4_1034_e516045de3b8["isTagValidWithParent()"] 99b6f05f_c8d3_afa4_842b_34ebebb1f8a7["validateDOMNesting.js"] af0fc495_4d30_0fb4_1034_e516045de3b8 -->|defined in| 99b6f05f_c8d3_afa4_842b_34ebebb1f8a7 96e5c4d9_bcbf_86ea_69bb_cc3d02fbd794["validateDOMNesting()"] 96e5c4d9_bcbf_86ea_69bb_cc3d02fbd794 -->|calls| af0fc495_4d30_0fb4_1034_e516045de3b8 9805d2a0_a12e_fb58_a873_c63b02425b81["validateTextNesting()"] 9805d2a0_a12e_fb58_a873_c63b02425b81 -->|calls| af0fc495_4d30_0fb4_1034_e516045de3b8 style af0fc495_4d30_0fb4_1034_e516045de3b8 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/react-dom-bindings/src/client/validateDOMNesting.js lines 302–460
function isTagValidWithParent(
tag: string,
parentTag: ?string,
implicitRootScope: boolean,
): boolean {
// First, let's check if we're in an unusual parsing mode...
switch (parentTag) {
// https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inselect
case 'select':
return (
tag === 'hr' ||
tag === 'option' ||
tag === 'optgroup' ||
tag === 'script' ||
tag === 'template' ||
tag === '#text'
);
case 'optgroup':
return tag === 'option' || tag === '#text';
// Strictly speaking, seeing an <option> doesn't mean we're in a <select>
// but
case 'option':
return tag === '#text';
// https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-intd
// https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-incaption
// No special behavior since these rules fall back to "in body" mode for
// all except special table nodes which cause bad parsing behavior anyway.
// https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-intr
case 'tr':
return (
tag === 'th' ||
tag === 'td' ||
tag === 'style' ||
tag === 'script' ||
tag === 'template'
);
// https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-intbody
case 'tbody':
case 'thead':
case 'tfoot':
return (
tag === 'tr' ||
tag === 'style' ||
tag === 'script' ||
tag === 'template'
);
// https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-incolgroup
case 'colgroup':
return tag === 'col' || tag === 'template';
// https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-intable
case 'table':
return (
tag === 'caption' ||
tag === 'colgroup' ||
tag === 'tbody' ||
tag === 'tfoot' ||
tag === 'thead' ||
tag === 'style' ||
tag === 'script' ||
tag === 'template'
);
// https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inhead
case 'head':
return (
tag === 'base' ||
tag === 'basefont' ||
tag === 'bgsound' ||
tag === 'link' ||
tag === 'meta' ||
tag === 'title' ||
tag === 'noscript' ||
tag === 'noframes' ||
tag === 'style' ||
tag === 'script' ||
tag === 'template'
);
// https://html.spec.whatwg.org/multipage/semantics.html#the-html-element
case 'html':
if (implicitRootScope) {
// When our parent tag is html and we're in the root scope we will actually
Domain
Subdomains
Source
Frequently Asked Questions
What does isTagValidWithParent() do?
isTagValidWithParent() is a function in the react codebase, defined in packages/react-dom-bindings/src/client/validateDOMNesting.js.
Where is isTagValidWithParent() defined?
isTagValidWithParent() is defined in packages/react-dom-bindings/src/client/validateDOMNesting.js at line 302.
What calls isTagValidWithParent()?
isTagValidWithParent() is called by 2 function(s): validateDOMNesting, validateTextNesting.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free