RegularElement() — svelte Function Reference
Architecture documentation for the RegularElement() function in RegularElement.js from the svelte codebase.
Entity Profile
Dependency Diagram
graph TD 1e3b81f2_cd53_e5a5_0140_a9af38facf99["RegularElement()"] 4610488f_3cf2_5f73_043e_da0aa9d026fe["RegularElement.js"] 1e3b81f2_cd53_e5a5_0140_a9af38facf99 -->|defined in| 4610488f_3cf2_5f73_043e_da0aa9d026fe af756561_34dc_505a_86e2_23aef4b7c333["push_element()"] 1e3b81f2_cd53_e5a5_0140_a9af38facf99 -->|calls| af756561_34dc_505a_86e2_23aef4b7c333 58d8098f_7692_f2fb_4a0f_6b486490cd6d["pop_element()"] 1e3b81f2_cd53_e5a5_0140_a9af38facf99 -->|calls| 58d8098f_7692_f2fb_4a0f_6b486490cd6d 76437ce7_73fa_a7f2_397a_1ddd381e8282["is_custom_element_node()"] 1e3b81f2_cd53_e5a5_0140_a9af38facf99 -->|calls| 76437ce7_73fa_a7f2_397a_1ddd381e8282 e31bc2c2_91c1_b9a9_f78a_2832bddce6c5["build_attribute_value()"] 1e3b81f2_cd53_e5a5_0140_a9af38facf99 -->|calls| e31bc2c2_91c1_b9a9_f78a_2832bddce6c5 034e8348_972b_e1ae_32c8_9476392e9799["set_prop()"] 1e3b81f2_cd53_e5a5_0140_a9af38facf99 -->|calls| 034e8348_972b_e1ae_32c8_9476392e9799 653284b2_68fd_eee3_0064_918a4c065d4a["is_text_attribute()"] 1e3b81f2_cd53_e5a5_0140_a9af38facf99 -->|calls| 653284b2_68fd_eee3_0064_918a4c065d4a bfe6ef19_8d05_fa85_483b_09ebcc1130d8["setup_select_synchronization()"] 1e3b81f2_cd53_e5a5_0140_a9af38facf99 -->|calls| bfe6ef19_8d05_fa85_483b_09ebcc1130d8 ef858948_a3b7_f31d_ad40_16743e642d00["build_attribute_effect()"] 1e3b81f2_cd53_e5a5_0140_a9af38facf99 -->|calls| ef858948_a3b7_f31d_ad40_16743e642d00 e9a2c29e_d0ca_ab9f_b86f_f22ff802db91["is_event_attribute()"] 1e3b81f2_cd53_e5a5_0140_a9af38facf99 -->|calls| e9a2c29e_d0ca_ab9f_b86f_f22ff802db91 e35222ea_3daa_de5e_3d5f_66469f2fb218["visit_event_attribute()"] 1e3b81f2_cd53_e5a5_0140_a9af38facf99 -->|calls| e35222ea_3daa_de5e_3d5f_66469f2fb218 c8721427_6276_3a58_b479_ed36758d95bc["get_attribute_name()"] 1e3b81f2_cd53_e5a5_0140_a9af38facf99 -->|calls| c8721427_6276_3a58_b479_ed36758d95bc 236530b5_f75d_4a7b_e916_b2d6a6d54dfb["cannot_be_set_statically()"] 1e3b81f2_cd53_e5a5_0140_a9af38facf99 -->|calls| 236530b5_f75d_4a7b_e916_b2d6a6d54dfb 573f9041_7062_5e5d_80e6_7292990c13c5["build_set_class()"] 1e3b81f2_cd53_e5a5_0140_a9af38facf99 -->|calls| 573f9041_7062_5e5d_80e6_7292990c13c5 style 1e3b81f2_cd53_e5a5_0140_a9af38facf99 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/svelte/src/compiler/phases/3-transform/client/visitors/RegularElement.js lines 40–502
export function RegularElement(node, context) {
context.state.template.push_element(node.name, node.start);
if (node.name === 'noscript') {
context.state.template.pop_element();
return;
}
const is_custom_element = is_custom_element_node(node);
// cloneNode is faster, but it does not instantiate the underlying class of the
// custom element until the template is connected to the dom, which would
// cause problems when setting properties on the custom element.
// Therefore we need to use importNode instead, which doesn't have this caveat.
// Additionally, Webkit browsers need importNode for video elements for autoplay
// to work correctly.
context.state.template.needs_import_node ||= node.name === 'video' || is_custom_element;
context.state.template.contains_script_tag ||= node.name === 'script';
/** @type {Array<AST.Attribute | AST.SpreadAttribute>} */
const attributes = [];
/** @type {AST.ClassDirective[]} */
const class_directives = [];
/** @type {AST.StyleDirective[]} */
const style_directives = [];
/** @type {Array<AST.AnimateDirective | AST.BindDirective | AST.OnDirective | AST.TransitionDirective | AST.UseDirective | AST.AttachTag>} */
const other_directives = [];
/** @type {ExpressionStatement[]} */
const lets = [];
/** @type {Map<string, AST.Attribute>} */
const lookup = new Map();
/** @type {Map<string, AST.BindDirective>} */
const bindings = new Map();
let has_spread = node.metadata.has_spread;
let has_use = false;
let should_remove_defaults = false;
for (const attribute of node.attributes) {
switch (attribute.type) {
case 'AnimateDirective':
other_directives.push(attribute);
break;
case 'Attribute':
// `is` attributes need to be part of the template, otherwise they break
if (attribute.name === 'is' && context.state.metadata.namespace === 'html') {
const { value } = build_attribute_value(attribute.value, context);
if (value.type === 'Literal' && typeof value.value === 'string') {
context.state.template.set_prop('is', value.value);
continue;
}
}
attributes.push(attribute);
lookup.set(attribute.name, attribute);
break;
case 'BindDirective':
bindings.set(attribute.name, attribute);
other_directives.push(attribute);
break;
case 'ClassDirective':
class_directives.push(attribute);
break;
case 'LetDirective':
// visit let directives before everything else, to set state
context.visit(attribute, { ...context.state, let_directives: lets });
break;
case 'OnDirective':
Domain
Subdomains
Calls
- add()
- build_attribute_effect()
- build_attribute_value()
- build_custom_element_attribute_update_assignment()
- build_element_attribute_update()
- build_element_special_value_attribute()
- build_render_statement()
- build_set_class()
- build_set_style()
- build_template_chunk()
- cannot_be_set_statically()
- clean_nodes()
- create_attribute()
- determine_namespace_for_children()
- get_attribute_name()
- has_blockers()
- is_custom_element_node()
- is_customizable_select_element()
- is_event_attribute()
- is_load_error_element()
- is_static_element()
- is_text_attribute()
- pop_element()
- process_children()
- push_comment()
- push_element()
- set_prop()
- setup_select_synchronization()
- transform_template()
- visit_event_attribute()
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/client/visitors/RegularElement.js.
Where is RegularElement() defined?
RegularElement() is defined in packages/svelte/src/compiler/phases/3-transform/client/visitors/RegularElement.js at line 40.
What does RegularElement() call?
RegularElement() calls 30 function(s): add, build_attribute_effect, build_attribute_value, build_custom_element_attribute_update_assignment, build_element_attribute_update, build_element_special_value_attribute, build_render_statement, build_set_class, and 22 more.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free