attribute_effect() — svelte Function Reference
Architecture documentation for the attribute_effect() function in attributes.js from the svelte codebase.
Entity Profile
Dependency Diagram
graph TD 9a87a496_4e7d_9214_8bba_7bb2e3e47939["attribute_effect()"] 0acd2537_e1bf_d7ae_30d5_407378cfa4d3["attributes.js"] 9a87a496_4e7d_9214_8bba_7bb2e3e47939 -->|defined in| 0acd2537_e1bf_d7ae_30d5_407378cfa4d3 b9aaaccb_7510_28de_bb53_f808b2cb1d5e["flatten()"] 9a87a496_4e7d_9214_8bba_7bb2e3e47939 -->|calls| b9aaaccb_7510_28de_bb53_f808b2cb1d5e a3686fa4_d487_d514_9dcd_bcbf5853b659["managed()"] 9a87a496_4e7d_9214_8bba_7bb2e3e47939 -->|calls| a3686fa4_d487_d514_9dcd_bcbf5853b659 4c70ef10_16f1_40f4_1d51_8a7169bd1dba["set_attributes()"] 9a87a496_4e7d_9214_8bba_7bb2e3e47939 -->|calls| 4c70ef10_16f1_40f4_1d51_8a7169bd1dba 35049132_3e86_afd7_a475_924b092a0c2b["select_option()"] 9a87a496_4e7d_9214_8bba_7bb2e3e47939 -->|calls| 35049132_3e86_afd7_a475_924b092a0c2b 410f774f_2d1a_7114_fcba_b292ed7cae3a["destroy_effect()"] 9a87a496_4e7d_9214_8bba_7bb2e3e47939 -->|calls| 410f774f_2d1a_7114_fcba_b292ed7cae3a 4ca1b5f2_087e_afec_72d9_534a30fbfe1f["branch()"] 9a87a496_4e7d_9214_8bba_7bb2e3e47939 -->|calls| 4ca1b5f2_087e_afec_72d9_534a30fbfe1f 4133c9ed_6ce6_0847_e62e_62aaf8690ab4["attach()"] 9a87a496_4e7d_9214_8bba_7bb2e3e47939 -->|calls| 4133c9ed_6ce6_0847_e62e_62aaf8690ab4 a985ae40_8ef8_7ef2_adad_116fbf97e70c["effect()"] 9a87a496_4e7d_9214_8bba_7bb2e3e47939 -->|calls| a985ae40_8ef8_7ef2_adad_116fbf97e70c 69a43253_5c15_5f06_b28b_0c8b251c8edd["init_select()"] 9a87a496_4e7d_9214_8bba_7bb2e3e47939 -->|calls| 69a43253_5c15_5f06_b28b_0c8b251c8edd style 9a87a496_4e7d_9214_8bba_7bb2e3e47939 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/svelte/src/internal/client/dom/elements/attributes.js lines 491–556
export function attribute_effect(
element,
fn,
sync = [],
async = [],
blockers = [],
css_hash,
should_remove_defaults = false,
skip_warning = false
) {
flatten(blockers, sync, async, (values) => {
/** @type {Record<string | symbol, any> | undefined} */
var prev = undefined;
/** @type {Record<symbol, Effect>} */
var effects = {};
var is_select = element.nodeName === 'SELECT';
var inited = false;
managed(() => {
var next = fn(...values.map(get));
/** @type {Record<string | symbol, any>} */
var current = set_attributes(
element,
prev,
next,
css_hash,
should_remove_defaults,
skip_warning
);
if (inited && is_select && 'value' in next) {
select_option(/** @type {HTMLSelectElement} */ (element), next.value);
}
for (let symbol of Object.getOwnPropertySymbols(effects)) {
if (!next[symbol]) destroy_effect(effects[symbol]);
}
for (let symbol of Object.getOwnPropertySymbols(next)) {
var n = next[symbol];
if (symbol.description === ATTACHMENT_KEY && (!prev || n !== prev[symbol])) {
if (effects[symbol]) destroy_effect(effects[symbol]);
effects[symbol] = branch(() => attach(element, () => n));
}
current[symbol] = n;
}
prev = current;
});
if (is_select) {
var select = /** @type {HTMLSelectElement} */ (element);
effect(() => {
select_option(select, /** @type {Record<string | symbol, any>} */ (prev).value, true);
init_select(select);
});
}
inited = true;
});
}
Domain
Subdomains
Calls
Source
Frequently Asked Questions
What does attribute_effect() do?
attribute_effect() is a function in the svelte codebase, defined in packages/svelte/src/internal/client/dom/elements/attributes.js.
Where is attribute_effect() defined?
attribute_effect() is defined in packages/svelte/src/internal/client/dom/elements/attributes.js at line 491.
What does attribute_effect() call?
attribute_effect() calls 9 function(s): attach, branch, destroy_effect, effect, flatten, init_select, managed, select_option, and 1 more.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free