SvelteElement.js — svelte Source File
Architecture documentation for SvelteElement.js, a javascript file in the svelte codebase. 9 imports, 1 dependents.
Entity Profile
Dependency Diagram
graph LR f7b5a3fc_d53e_8647_11c4_d826334aec0c["SvelteElement.js"] 73865c3c_2786_c9ac_d34f_b51d28b3a29e["constants.js"] f7b5a3fc_d53e_8647_11c4_d826334aec0c --> 73865c3c_2786_c9ac_d34f_b51d28b3a29e 0c5c28a7_226d_4e7c_e75e_0853c0a9fc2c["ast.js"] f7b5a3fc_d53e_8647_11c4_d826334aec0c --> 0c5c28a7_226d_4e7c_e75e_0853c0a9fc2c 653284b2_68fd_eee3_0064_918a4c065d4a["is_text_attribute"] f7b5a3fc_d53e_8647_11c4_d826334aec0c --> 653284b2_68fd_eee3_0064_918a4c065d4a b389a21f_6de7_2a41_34f3_8efbf9045c9c["index.js"] f7b5a3fc_d53e_8647_11c4_d826334aec0c --> b389a21f_6de7_2a41_34f3_8efbf9045c9c c342967b_b314_8027_476d_d085ed0e13f0["check_element"] f7b5a3fc_d53e_8647_11c4_d826334aec0c --> c342967b_b314_8027_476d_d085ed0e13f0 bab84a6b_4a21_0643_e6ee_13798dfa8b84["element.js"] f7b5a3fc_d53e_8647_11c4_d826334aec0c --> bab84a6b_4a21_0643_e6ee_13798dfa8b84 8b731563_0657_df8d_6a4b_cd33990e2ed2["validate_element"] f7b5a3fc_d53e_8647_11c4_d826334aec0c --> 8b731563_0657_df8d_6a4b_cd33990e2ed2 c4b4ac8d_9914_5ede_1aea_723bf80d2e9b["fragment.js"] f7b5a3fc_d53e_8647_11c4_d826334aec0c --> c4b4ac8d_9914_5ede_1aea_723bf80d2e9b 313d2a82_30ea_3161_3aad_0cc2094979aa["mark_subtree_dynamic"] f7b5a3fc_d53e_8647_11c4_d826334aec0c --> 313d2a82_30ea_3161_3aad_0cc2094979aa 4aa8a188_84d4_0274_ed83_cac0ab1d3572["index.js"] 4aa8a188_84d4_0274_ed83_cac0ab1d3572 --> f7b5a3fc_d53e_8647_11c4_d826334aec0c style f7b5a3fc_d53e_8647_11c4_d826334aec0c fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
/** @import { AST } from '#compiler' */
/** @import { Context } from '../types' */
import { NAMESPACE_MATHML, NAMESPACE_SVG } from '../../../../constants.js';
import { is_text_attribute } from '../../../utils/ast.js';
import { check_element } from './shared/a11y/index.js';
import { validate_element } from './shared/element.js';
import { mark_subtree_dynamic } from './shared/fragment.js';
/**
* @param {AST.SvelteElement} node
* @param {Context} context
*/
export function SvelteElement(node, context) {
validate_element(node, context);
check_element(node, context);
node.metadata.path = [...context.path];
context.state.analysis.elements.push(node);
const xmlns = /** @type {AST.Attribute & { value: [AST.Text] } | undefined} */ (
node.attributes.find(
(a) => a.type === 'Attribute' && a.name === 'xmlns' && is_text_attribute(a)
)
);
if (xmlns) {
node.metadata.svg = xmlns.value[0].data === NAMESPACE_SVG;
node.metadata.mathml = xmlns.value[0].data === NAMESPACE_MATHML;
} else {
let i = context.path.length;
while (i--) {
const ancestor = context.path[i];
if (
ancestor.type === 'Component' ||
ancestor.type === 'SvelteComponent' ||
ancestor.type === 'SvelteFragment' ||
ancestor.type === 'SnippetBlock' ||
i === 0
) {
// Root element, or inside a slot or a snippet -> this resets the namespace, so assume the component namespace
node.metadata.svg = context.state.options.namespace === 'svg';
node.metadata.mathml = context.state.options.namespace === 'mathml';
break;
}
if (ancestor.type === 'SvelteElement' || ancestor.type === 'RegularElement') {
node.metadata.svg =
ancestor.type === 'RegularElement' && ancestor.name === 'foreignObject'
? false
: ancestor.metadata.svg;
node.metadata.mathml =
ancestor.type === 'RegularElement' && ancestor.name === 'foreignObject'
? false
: ancestor.metadata.mathml;
break;
}
}
}
mark_subtree_dynamic(context.path);
context.visit(node.tag, {
...context.state,
expression: node.metadata.expression
});
for (const attribute of node.attributes) {
context.visit(attribute);
}
context.visit(node.fragment, {
...context.state,
parent_element: null
});
}
Domain
Subdomains
Functions
Dependencies
Source
Frequently Asked Questions
What does SvelteElement.js do?
SvelteElement.js is a source file in the svelte codebase, written in javascript. It belongs to the Compiler domain, Transformer subdomain.
What functions are defined in SvelteElement.js?
SvelteElement.js defines 1 function(s): SvelteElement.
What does SvelteElement.js depend on?
SvelteElement.js imports 9 module(s): ast.js, check_element, constants.js, element.js, fragment.js, index.js, is_text_attribute, mark_subtree_dynamic, and 1 more.
What files import SvelteElement.js?
SvelteElement.js is imported by 1 file(s): index.js.
Where is SvelteElement.js in the architecture?
SvelteElement.js is located at packages/svelte/src/compiler/phases/2-analyze/visitors/SvelteElement.js (domain: Compiler, subdomain: Transformer, directory: packages/svelte/src/compiler/phases/2-analyze/visitors).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free