build_attr_style() — svelte Function Reference
Architecture documentation for the build_attr_style() function in element.js from the svelte codebase.
Entity Profile
Dependency Diagram
graph TD 83a6f8a7_8a40_53b5_1606_ee9a8a0c506a["build_attr_style()"] 090475a4_80b3_421f_579a_0e67cde619eb["element.js"] 83a6f8a7_8a40_53b5_1606_ee9a8a0c506a -->|defined in| 090475a4_80b3_421f_579a_0e67cde619eb 53e2b89f_4f0e_65bc_dc56_d40e6427ed9b["build_element_attributes()"] 53e2b89f_4f0e_65bc_dc56_d40e6427ed9b -->|calls| 83a6f8a7_8a40_53b5_1606_ee9a8a0c506a 9692c2d4_ebab_93ed_8431_6b0fd23a8b78["build_attribute_value()"] 83a6f8a7_8a40_53b5_1606_ee9a8a0c506a -->|calls| 9692c2d4_ebab_93ed_8431_6b0fd23a8b78 494ad35f_066a_eaba_ab89_2ae759e5e121["object()"] 83a6f8a7_8a40_53b5_1606_ee9a8a0c506a -->|calls| 494ad35f_066a_eaba_ab89_2ae759e5e121 style 83a6f8a7_8a40_53b5_1606_ee9a8a0c506a fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/svelte/src/compiler/phases/3-transform/server/visitors/shared/element.js lines 522–557
function build_attr_style(style_directives, expression, context, transform) {
/** @type {ArrayExpression | ObjectExpression | undefined} */
let directives;
if (style_directives.length) {
let normal_properties = [];
let important_properties = [];
for (const directive of style_directives) {
const expression =
directive.value === true
? b.id(directive.name)
: build_attribute_value(directive.value, context, transform, true);
let name = directive.name;
if (name[0] !== '-' || name[1] !== '-') {
name = name.toLowerCase();
}
const property = b.init(name, expression);
if (directive.modifiers.includes('important')) {
important_properties.push(property);
} else {
normal_properties.push(property);
}
}
if (important_properties.length) {
directives = b.array([b.object(normal_properties), b.object(important_properties)]);
} else {
directives = b.object(normal_properties);
}
}
return b.call('$.attr_style', expression, directives);
}
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does build_attr_style() do?
build_attr_style() is a function in the svelte codebase, defined in packages/svelte/src/compiler/phases/3-transform/server/visitors/shared/element.js.
Where is build_attr_style() defined?
build_attr_style() is defined in packages/svelte/src/compiler/phases/3-transform/server/visitors/shared/element.js at line 522.
What does build_attr_style() call?
build_attr_style() calls 2 function(s): build_attribute_value, object.
What calls build_attr_style()?
build_attr_style() is called by 1 function(s): build_element_attributes.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free