MCPcopy Index your code
hub / github.com/react/react / hydrateAttribute

Function hydrateAttribute

packages/react-dom-bindings/src/client/ReactDOMComponent.js:2025–2065  ·  view source on GitHub ↗
(
  domElement: Element,
  propKey: string,
  attributeName: string,
  value: any,
  extraAttributes: Set<string>,
  serverDifferences: {[propName: string]: mixed},
)

Source from the content-addressed store, hash-verified

2023}
2024
2025function hydrateAttribute(
2026 domElement: Element,
2027 propKey: string,
2028 attributeName: string,
2029 value: any,
2030 extraAttributes: Set<string>,
2031 serverDifferences: {[propName: string]: mixed},
2032): void {
2033 extraAttributes.delete(attributeName);
2034 const serverValue = domElement.getAttribute(attributeName);
2035 if (serverValue === null) {
2036 switch (typeof value) {
2037 case 'undefined':
2038 case 'function':
2039 case 'symbol':
2040 case 'boolean':
2041 return;
2042 }
2043 } else {
2044 if (value == null) {
2045 // We had an attribute but shouldn't have had one, so read it
2046 // for the error message.
2047 } else {
2048 switch (typeof value) {
2049 case 'function':
2050 case 'symbol':
2051 case 'boolean':
2052 break;
2053 default: {
2054 if (__DEV__) {
2055 checkAttributeStringCoercion(value, propKey);
2056 }
2057 if (serverValue === '' + value) {
2058 return;
2059 }
2060 }
2061 }
2062 }
2063 }
2064 warnForPropDifference(propKey, serverValue, value, serverDifferences);
2065}
2066
2067function hydrateBooleanAttribute(
2068 domElement: Element,

Callers 1

Calls 2

warnForPropDifferenceFunction · 0.85

Tested by

no test coverage detected