MCPcopy Create free account
hub / github.com/reactjs/react-rails / setInitialDOMProperties

Function setInitialDOMProperties

lib/assets/react-source/development/react.js:9478–9529  ·  view source on GitHub ↗
(tag, domElement, rootContainerElement, nextProps, isCustomComponentTag)

Source from the content-addressed store, hash-verified

9476 }
9477
9478 function setInitialDOMProperties(tag, domElement, rootContainerElement, nextProps, isCustomComponentTag) {
9479 for (var propKey in nextProps) {
9480 if (!nextProps.hasOwnProperty(propKey)) {
9481 continue;
9482 }
9483
9484 var nextProp = nextProps[propKey];
9485
9486 if (propKey === STYLE) {
9487 {
9488 if (nextProp) {
9489 // Freeze the next style object so that we can assume it won't be
9490 // mutated. We have already warned for this in the past.
9491 Object.freeze(nextProp);
9492 }
9493 } // Relies on `updateStylesByID` not mutating `styleUpdates`.
9494
9495
9496 setValueForStyles(domElement, nextProp);
9497 } else if (propKey === DANGEROUSLY_SET_INNER_HTML) {
9498 var nextHtml = nextProp ? nextProp[HTML$1] : undefined;
9499
9500 if (nextHtml != null) {
9501 setInnerHTML(domElement, nextHtml);
9502 }
9503 } else if (propKey === CHILDREN) {
9504 if (typeof nextProp === 'string') {
9505 // Avoid setting initial textContent when the text is empty. In IE11 setting
9506 // textContent on a <textarea> will cause the placeholder to not
9507 // show within the <textarea> until it has been focused and blurred again.
9508 // https://github.com/facebook/react/issues/6731#issuecomment-254874553
9509 var canSetTextContent = tag !== 'textarea' || nextProp !== '';
9510
9511 if (canSetTextContent) {
9512 setTextContent(domElement, nextProp);
9513 }
9514 } else if (typeof nextProp === 'number') {
9515 setTextContent(domElement, '' + nextProp);
9516 }
9517 } else if ( propKey === SUPPRESS_CONTENT_EDITABLE_WARNING || propKey === SUPPRESS_HYDRATION_WARNING) ; else if (propKey === AUTOFOCUS) ; else if (registrationNameModules.hasOwnProperty(propKey)) {
9518 if (nextProp != null) {
9519 if ( typeof nextProp !== 'function') {
9520 warnForInvalidEventListener(propKey, nextProp);
9521 }
9522
9523 ensureListeningTo(rootContainerElement, propKey);
9524 }
9525 } else if (nextProp != null) {
9526 setValueForProperty(domElement, propKey, nextProp, isCustomComponentTag);
9527 }
9528 }
9529 }
9530
9531 function updateDOMProperties(domElement, updatePayload, wasCustomComponentTag, isCustomComponentTag) {
9532 // TODO: Handle wasCustomComponentTag

Callers 1

setInitialPropertiesFunction · 0.85

Calls 4

setValueForStylesFunction · 0.85
setTextContentFunction · 0.85
ensureListeningToFunction · 0.85
setValueForPropertyFunction · 0.85

Tested by

no test coverage detected