set_attribute() — svelte Function Reference
Architecture documentation for the set_attribute() function in attributes.js from the svelte codebase.
Entity Profile
Dependency Diagram
graph TD a305388e_cd72_059e_c54e_36001ca30e0a["set_attribute()"] 0acd2537_e1bf_d7ae_30d5_407378cfa4d3["attributes.js"] a305388e_cd72_059e_c54e_36001ca30e0a -->|defined in| 0acd2537_e1bf_d7ae_30d5_407378cfa4d3 12da86e1_c608_1c76_660b_570e483dc67a["remove_input_defaults()"] 12da86e1_c608_1c76_660b_570e483dc67a -->|calls| a305388e_cd72_059e_c54e_36001ca30e0a 0c0569a6_0fe6_ad48_18b5_235d70e8fd1f["set_custom_element_data()"] 0c0569a6_0fe6_ad48_18b5_235d70e8fd1f -->|calls| a305388e_cd72_059e_c54e_36001ca30e0a 4c70ef10_16f1_40f4_1d51_8a7169bd1dba["set_attributes()"] 4c70ef10_16f1_40f4_1d51_8a7169bd1dba -->|calls| a305388e_cd72_059e_c54e_36001ca30e0a 318223ca_87d5_a1fe_45e4_c1304dea610b["get_attributes()"] a305388e_cd72_059e_c54e_36001ca30e0a -->|calls| 318223ca_87d5_a1fe_45e4_c1304dea610b 111c4519_c7e6_3546_5a6f_e63970808b2e["check_src_in_dev_hydration()"] a305388e_cd72_059e_c54e_36001ca30e0a -->|calls| 111c4519_c7e6_3546_5a6f_e63970808b2e 1d3fa733_c8b9_7ca3_c600_2689a6e7c29d["get_setters()"] a305388e_cd72_059e_c54e_36001ca30e0a -->|calls| 1d3fa733_c8b9_7ca3_c600_2689a6e7c29d style a305388e_cd72_059e_c54e_36001ca30e0a fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/svelte/src/internal/client/dom/elements/attributes.js lines 162–200
export function set_attribute(element, attribute, value, skip_warning) {
var attributes = get_attributes(element);
if (hydrating) {
attributes[attribute] = element.getAttribute(attribute);
if (
attribute === 'src' ||
attribute === 'srcset' ||
(attribute === 'href' && element.nodeName === 'LINK')
) {
if (!skip_warning) {
check_src_in_dev_hydration(element, attribute, value ?? '');
}
// If we reset these attributes, they would result in another network request, which we want to avoid.
// We assume they are the same between client and server as checking if they are equal is expensive
// (we can't just compare the strings as they can be different between client and server but result in the
// same url, so we would need to create hidden anchor elements to compare them)
return;
}
}
if (attributes[attribute] === (attributes[attribute] = value)) return;
if (attribute === 'loading') {
// @ts-expect-error
element[LOADING_ATTR_SYMBOL] = value;
}
if (value == null) {
element.removeAttribute(attribute);
} else if (typeof value !== 'string' && get_setters(element).includes(attribute)) {
// @ts-ignore
element[attribute] = value;
} else {
element.setAttribute(attribute, value);
}
}
Domain
Subdomains
Source
Frequently Asked Questions
What does set_attribute() do?
set_attribute() is a function in the svelte codebase, defined in packages/svelte/src/internal/client/dom/elements/attributes.js.
Where is set_attribute() defined?
set_attribute() is defined in packages/svelte/src/internal/client/dom/elements/attributes.js at line 162.
What does set_attribute() call?
set_attribute() calls 3 function(s): check_src_in_dev_hydration, get_attributes, get_setters.
What calls set_attribute()?
set_attribute() is called by 3 function(s): remove_input_defaults, set_attributes, set_custom_element_data.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free