Home / File/ html-tree-validation.js — svelte Source File

html-tree-validation.js — svelte Source File

Architecture documentation for html-tree-validation.js, a javascript file in the svelte codebase. 0 imports, 5 dependents.

File javascript SharedInternal BitFlags 5 dependents 3 functions

Entity Profile

Dependency Diagram

graph LR
  302f84f3_ec7c_fd57_5b8e_e2f3ec2953b7["html-tree-validation.js"]
  206889ff_1f9f_b6c1_d530_059d001e1cf4["element.js"]
  206889ff_1f9f_b6c1_d530_059d001e1cf4 --> 302f84f3_ec7c_fd57_5b8e_e2f3ec2953b7
  563e8414_1dd4_f5bf_e346_91afa5cea4b9["ExpressionTag.js"]
  563e8414_1dd4_f5bf_e346_91afa5cea4b9 --> 302f84f3_ec7c_fd57_5b8e_e2f3ec2953b7
  60af7ccf_2ceb_e5af_2432_c5b753a12c2a["RegularElement.js"]
  60af7ccf_2ceb_e5af_2432_c5b753a12c2a --> 302f84f3_ec7c_fd57_5b8e_e2f3ec2953b7
  f8debeb0_6284_1c94_22a8_0f28192b28a5["Text.js"]
  f8debeb0_6284_1c94_22a8_0f28192b28a5 --> 302f84f3_ec7c_fd57_5b8e_e2f3ec2953b7
  4440efa2_b84c_d186_53ca_534b0add2937["dev.js"]
  4440efa2_b84c_d186_53ca_534b0add2937 --> 302f84f3_ec7c_fd57_5b8e_e2f3ec2953b7
  style 302f84f3_ec7c_fd57_5b8e_e2f3ec2953b7 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

/**
 * Map of elements that have certain elements that are not allowed inside them, in the sense that they will auto-close the parent/ancestor element.
 * Theoretically one could take advantage of it but most of the time it will just result in confusing behavior and break when SSR'd.
 * There are more elements that are invalid inside other elements, but they're not auto-closed and so don't break SSR and are therefore not listed here.
 * @type {Record<string, { direct: string[]} | { descendant: string[]; reset_by?: string[] }>}
 */
const autoclosing_children = {
	// based on http://developers.whatwg.org/syntax.html#syntax-tag-omission
	li: { direct: ['li'] },
	// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/dt#technical_summary
	dt: { descendant: ['dt', 'dd'], reset_by: ['dl'] },
	dd: { descendant: ['dt', 'dd'], reset_by: ['dl'] },
	p: {
		descendant: [
			'address',
			'article',
			'aside',
			'blockquote',
			'div',
			'dl',
			'fieldset',
			'footer',
			'form',
			'h1',
			'h2',
			'h3',
			'h4',
			'h5',
			'h6',
			'header',
			'hgroup',
			'hr',
			'main',
			'menu',
			'nav',
			'ol',
			'p',
			'pre',
			'section',
			'table',
			'ul'
		]
	},
	rt: { descendant: ['rt', 'rp'] },
	rp: { descendant: ['rt', 'rp'] },
	optgroup: { descendant: ['optgroup'] },
	option: { descendant: ['option', 'optgroup'] },
	thead: { direct: ['tbody', 'tfoot'] },
	tbody: { direct: ['tbody', 'tfoot'] },
	tfoot: { direct: ['tbody'] },
	tr: { direct: ['tr', 'tbody'] },
	td: { direct: ['td', 'th', 'tr'] },
	th: { direct: ['td', 'th', 'tr'] }
};

/**
 * Returns true if the tag is either the last in the list of siblings and will be autoclosed,
 * or not allowed inside the parent tag such that it will auto-close it. The latter results
 * in the browser repairing the HTML, which will likely result in an error during hydration.
 * @param {string} current
// ... (179 more lines)

Subdomains

Frequently Asked Questions

What does html-tree-validation.js do?
html-tree-validation.js is a source file in the svelte codebase, written in javascript. It belongs to the SharedInternal domain, BitFlags subdomain.
What functions are defined in html-tree-validation.js?
html-tree-validation.js defines 3 function(s): closing_tag_omitted, is_tag_valid_with_ancestor, is_tag_valid_with_parent.
What files import html-tree-validation.js?
html-tree-validation.js is imported by 5 file(s): ExpressionTag.js, RegularElement.js, Text.js, dev.js, element.js.
Where is html-tree-validation.js in the architecture?
html-tree-validation.js is located at packages/svelte/src/html-tree-validation.js (domain: SharedInternal, subdomain: BitFlags, directory: packages/svelte/src).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free