set_custom_element_data() — svelte Function Reference
Architecture documentation for the set_custom_element_data() function in attributes.js from the svelte codebase.
Entity Profile
Dependency Diagram
graph TD 0c0569a6_0fe6_ad48_18b5_235d70e8fd1f["set_custom_element_data()"] 0acd2537_e1bf_d7ae_30d5_407378cfa4d3["attributes.js"] 0c0569a6_0fe6_ad48_18b5_235d70e8fd1f -->|defined in| 0acd2537_e1bf_d7ae_30d5_407378cfa4d3 f5b61c69_d41c_bdb7_b931_5b8b3374332c["set_hydrating()"] 0c0569a6_0fe6_ad48_18b5_235d70e8fd1f -->|calls| f5b61c69_d41c_bdb7_b931_5b8b3374332c 311ef9f4_9b68_c178_c1db_3b8696f7d964["set_active_reaction()"] 0c0569a6_0fe6_ad48_18b5_235d70e8fd1f -->|calls| 311ef9f4_9b68_c178_c1db_3b8696f7d964 55623862_10b7_5361_e30b_34ec6941f1a7["set_active_effect()"] 0c0569a6_0fe6_ad48_18b5_235d70e8fd1f -->|calls| 55623862_10b7_5361_e30b_34ec6941f1a7 a08b6cc5_af73_1be4_d02f_3113cf8a8305["get()"] 0c0569a6_0fe6_ad48_18b5_235d70e8fd1f -->|calls| a08b6cc5_af73_1be4_d02f_3113cf8a8305 1d3fa733_c8b9_7ca3_c600_2689a6e7c29d["get_setters()"] 0c0569a6_0fe6_ad48_18b5_235d70e8fd1f -->|calls| 1d3fa733_c8b9_7ca3_c600_2689a6e7c29d a305388e_cd72_059e_c54e_36001ca30e0a["set_attribute()"] 0c0569a6_0fe6_ad48_18b5_235d70e8fd1f -->|calls| a305388e_cd72_059e_c54e_36001ca30e0a style 0c0569a6_0fe6_ad48_18b5_235d70e8fd1f fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/svelte/src/internal/client/dom/elements/attributes.js lines 216–263
export function set_custom_element_data(node, prop, value) {
// We need to ensure that setting custom element props, which can
// invoke lifecycle methods on other custom elements, does not also
// associate those lifecycle methods with the current active reaction
// or effect
var previous_reaction = active_reaction;
var previous_effect = active_effect;
// If we're hydrating but the custom element is from Svelte, and it already scaffolded,
// then it might run block logic in hydration mode, which we have to prevent.
let was_hydrating = hydrating;
if (hydrating) {
set_hydrating(false);
}
set_active_reaction(null);
set_active_effect(null);
try {
if (
// `style` should use `set_attribute` rather than the setter
prop !== 'style' &&
// Don't compute setters for custom elements while they aren't registered yet,
// because during their upgrade/instantiation they might add more setters.
// Instead, fall back to a simple "an object, then set as property" heuristic.
(setters_cache.has(node.getAttribute('is') || node.nodeName) ||
// customElements may not be available in browser extension contexts
!customElements ||
customElements.get(node.getAttribute('is') || node.tagName.toLowerCase())
? get_setters(node).includes(prop)
: value && typeof value === 'object')
) {
// @ts-expect-error
node[prop] = value;
} else {
// We did getters etc checks already, stringify before passing to set_attribute
// to ensure it doesn't invoke the same logic again, and potentially populating
// the setters cache too early.
set_attribute(node, prop, value == null ? value : String(value));
}
} finally {
set_active_reaction(previous_reaction);
set_active_effect(previous_effect);
if (was_hydrating) {
set_hydrating(true);
}
}
}
Domain
Subdomains
Source
Frequently Asked Questions
What does set_custom_element_data() do?
set_custom_element_data() is a function in the svelte codebase, defined in packages/svelte/src/internal/client/dom/elements/attributes.js.
Where is set_custom_element_data() defined?
set_custom_element_data() is defined in packages/svelte/src/internal/client/dom/elements/attributes.js at line 216.
What does set_custom_element_data() call?
set_custom_element_data() calls 6 function(s): get, get_setters, set_active_effect, set_active_reaction, set_attribute, set_hydrating.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free