RegularElement() — svelte Function Reference
Architecture documentation for the RegularElement() function in RegularElement.js from the svelte codebase.
Entity Profile
Dependency Diagram
graph TD 602abe50_d235_587e_7077_a4250fe9dc79["RegularElement()"] 4022e2d8_1e79_6b7b_f1e7_0e8528bc6d82["RegularElement.js"] 602abe50_d235_587e_7077_a4250fe9dc79 -->|defined in| 4022e2d8_1e79_6b7b_f1e7_0e8528bc6d82 a475d4d0_a1fa_71f2_13d3_ba42155a8763["determine_namespace_for_children()"] 602abe50_d235_587e_7077_a4250fe9dc79 -->|calls| a475d4d0_a1fa_71f2_13d3_ba42155a8763 02a8b5a2_13c5_e5b3_1ed2_617763d0904d["is_void()"] 602abe50_d235_587e_7077_a4250fe9dc79 -->|calls| 02a8b5a2_13c5_e5b3_1ed2_617763d0904d 17370b4c_df64_f183_35da_1de383ea4963["build_element_attributes()"] 602abe50_d235_587e_7077_a4250fe9dc79 -->|calls| 17370b4c_df64_f183_35da_1de383ea4963 94797a73_c86f_f8e5_0dbd_d1012c2c1584["render()"] 602abe50_d235_587e_7077_a4250fe9dc79 -->|calls| 94797a73_c86f_f8e5_0dbd_d1012c2c1584 49bc6956_1326_e1db_837c_bb4db2493060["build_template()"] 602abe50_d235_587e_7077_a4250fe9dc79 -->|calls| 49bc6956_1326_e1db_837c_bb4db2493060 48b02cf8_c90b_7278_8655_c24e3431a4b3["clean_nodes()"] 602abe50_d235_587e_7077_a4250fe9dc79 -->|calls| 48b02cf8_c90b_7278_8655_c24e3431a4b3 4ec029f0_bbf8_66de_0dbf_d15eef3e10a0["process_children()"] 602abe50_d235_587e_7077_a4250fe9dc79 -->|calls| 4ec029f0_bbf8_66de_0dbf_d15eef3e10a0 6bb21aff_7c01_9593_26a7_a77307bf55bb["prepare_element_spread_object()"] 602abe50_d235_587e_7077_a4250fe9dc79 -->|calls| 6bb21aff_7c01_9593_26a7_a77307bf55bb 02aa96ac_ad32_58cd_41f5_e0ee1020af5f["is_customizable_select_element()"] 602abe50_d235_587e_7077_a4250fe9dc79 -->|calls| 02aa96ac_ad32_58cd_41f5_e0ee1020af5f 3b2a4fcc_2df2_7057_21b4_4cac59b8df61["is_async()"] 602abe50_d235_587e_7077_a4250fe9dc79 -->|calls| 3b2a4fcc_2df2_7057_21b4_4cac59b8df61 style 602abe50_d235_587e_7077_a4250fe9dc79 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/svelte/src/compiler/phases/3-transform/server/visitors/RegularElement.js lines 17–218
export function RegularElement(node, context) {
const namespace = determine_namespace_for_children(node, context.state.namespace);
/** @type {ComponentServerTransformState} */
const state = {
...context.state,
namespace,
preserve_whitespace:
context.state.preserve_whitespace || node.name === 'pre' || node.name === 'textarea',
init: [],
template: []
};
const node_is_void = is_void(node.name);
const optimiser = new PromiseOptimiser();
// If this element needs special handling (like <select value> / <option>),
// avoid calling build_element_attributes here to prevent evaluating/awaiting
// attribute expressions twice. We'll handle attributes in the special branch.
const is_select_special =
node.name === 'select' &&
node.attributes.some(
(attribute) =>
((attribute.type === 'Attribute' || attribute.type === 'BindDirective') &&
attribute.name === 'value') ||
attribute.type === 'SpreadAttribute'
);
const is_option_special = node.name === 'option';
const is_special = is_select_special || is_option_special;
let body = /** @type {Expression | null} */ (null);
if (!is_special) {
// only open the tag in the non-special path
state.template.push(b.literal(`<${node.name}`));
body = build_element_attributes(node, { ...context, state }, optimiser.transform);
state.template.push(b.literal(node_is_void ? '/>' : '>')); // add `/>` for XHTML compliance
}
if ((node.name === 'script' || node.name === 'style') && node.fragment.nodes.length === 1) {
state.template.push(
b.literal(/** @type {AST.Text} */ (node.fragment.nodes[0]).data),
b.literal(`</${node.name}>`)
);
context.state.template.push(
...optimiser.render([...state.init, ...build_template(state.template)])
);
return;
}
const { hoisted, trimmed } = clean_nodes(
node,
node.fragment.nodes,
context.path,
namespace,
{
...state,
scope: /** @type {Scope} */ (state.scopes.get(node.fragment))
},
state.preserve_whitespace,
state.options.preserveComments
);
for (const node of hoisted) {
context.visit(node, state);
}
if (dev) {
const location = locator(node.start);
state.template.push(
b.stmt(
b.call(
'$.push_element',
b.id('$$renderer'),
b.literal(node.name),
b.literal(location.line),
b.literal(location.column)
)
)
Domain
Subdomains
Calls
Source
Frequently Asked Questions
What does RegularElement() do?
RegularElement() is a function in the svelte codebase, defined in packages/svelte/src/compiler/phases/3-transform/server/visitors/RegularElement.js.
Where is RegularElement() defined?
RegularElement() is defined in packages/svelte/src/compiler/phases/3-transform/server/visitors/RegularElement.js at line 17.
What does RegularElement() call?
RegularElement() calls 10 function(s): build_element_attributes, build_template, clean_nodes, determine_namespace_for_children, is_async, is_customizable_select_element, is_void, prepare_element_spread_object, and 2 more.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free