setValueForAttribute() — react Function Reference
Architecture documentation for the setValueForAttribute() function in DOMPropertyOperations.js from the react codebase.
Entity Profile
Dependency Diagram
graph TD b75892dd_dacd_d978_2b97_090839521b0e["setValueForAttribute()"] 390123a6_56c3_29ed_a331_44deb86078d6["DOMPropertyOperations.js"] b75892dd_dacd_d978_2b97_090839521b0e -->|defined in| 390123a6_56c3_29ed_a331_44deb86078d6 7ef9c2ac_b7a6_04bb_4dac_940bd3dcfe7d["setValueForPropertyOnCustomComponent()"] 7ef9c2ac_b7a6_04bb_4dac_940bd3dcfe7d -->|calls| b75892dd_dacd_d978_2b97_090839521b0e 5a792874_dbaf_1dd0_9e62_d6a16580e0b5["setProp()"] 5a792874_dbaf_1dd0_9e62_d6a16580e0b5 -->|calls| b75892dd_dacd_d978_2b97_090839521b0e 328a0fd1_037f_e628_5343_b37fc3e7b33b["isAttributeNameSafe()"] b75892dd_dacd_d978_2b97_090839521b0e -->|calls| 328a0fd1_037f_e628_5343_b37fc3e7b33b style b75892dd_dacd_d978_2b97_090839521b0e fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/react-dom-bindings/src/client/DOMPropertyOperations.js lines 98–132
export function setValueForAttribute(
node: Element,
name: string,
value: mixed,
) {
if (isAttributeNameSafe(name)) {
// If the prop isn't in the special list, treat it as a simple attribute.
// shouldRemoveAttribute
if (value === null) {
node.removeAttribute(name);
return;
}
switch (typeof value) {
case 'undefined':
case 'function':
case 'symbol':
node.removeAttribute(name);
return;
case 'boolean': {
const prefix = name.toLowerCase().slice(0, 5);
if (prefix !== 'data-' && prefix !== 'aria-') {
node.removeAttribute(name);
return;
}
}
}
if (__DEV__) {
checkAttributeStringCoercion(value, name);
}
node.setAttribute(
name,
enableTrustedTypesIntegration ? (value: any) : '' + (value: any),
);
}
}
Domain
Subdomains
Calls
Source
Frequently Asked Questions
What does setValueForAttribute() do?
setValueForAttribute() is a function in the react codebase, defined in packages/react-dom-bindings/src/client/DOMPropertyOperations.js.
Where is setValueForAttribute() defined?
setValueForAttribute() is defined in packages/react-dom-bindings/src/client/DOMPropertyOperations.js at line 98.
What does setValueForAttribute() call?
setValueForAttribute() calls 1 function(s): isAttributeNameSafe.
What calls setValueForAttribute()?
setValueForAttribute() is called by 2 function(s): setProp, setValueForPropertyOnCustomComponent.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free