MCPcopy Create free account
hub / github.com/microsoft/SandDance / setInitialDOMProperties

Function setInitialDOMProperties

docs/external/js/react-dom.development.js:5906–5957  ·  view source on GitHub ↗
(tag, domElement, rootContainerElement, nextProps, isCustomComponentTag)

Source from the content-addressed store, hash-verified

5904 }
5905
5906 function setInitialDOMProperties(tag, domElement, rootContainerElement, nextProps, isCustomComponentTag) {
5907 for (var propKey in nextProps) {
5908 if (!nextProps.hasOwnProperty(propKey)) {
5909 continue;
5910 }
5911
5912 var nextProp = nextProps[propKey];
5913
5914 if (propKey === STYLE) {
5915 {
5916 if (nextProp) {
5917 // Freeze the next style object so that we can assume it won't be
5918 // mutated. We have already warned for this in the past.
5919 Object.freeze(nextProp);
5920 }
5921 } // Relies on `updateStylesByID` not mutating `styleUpdates`.
5922
5923
5924 setValueForStyles(domElement, nextProp);
5925 } else if (propKey === DANGEROUSLY_SET_INNER_HTML) {
5926 var nextHtml = nextProp ? nextProp[HTML$1] : undefined;
5927
5928 if (nextHtml != null) {
5929 setInnerHTML(domElement, nextHtml);
5930 }
5931 } else if (propKey === CHILDREN) {
5932 if (typeof nextProp === 'string') {
5933 // Avoid setting initial textContent when the text is empty. In IE11 setting
5934 // textContent on a <textarea> will cause the placeholder to not
5935 // show within the <textarea> until it has been focused and blurred again.
5936 // https://github.com/facebook/react/issues/6731#issuecomment-254874553
5937 var canSetTextContent = tag !== 'textarea' || nextProp !== '';
5938
5939 if (canSetTextContent) {
5940 setTextContent(domElement, nextProp);
5941 }
5942 } else if (typeof nextProp === 'number') {
5943 setTextContent(domElement, '' + nextProp);
5944 }
5945 } else if ( propKey === SUPPRESS_CONTENT_EDITABLE_WARNING || propKey === SUPPRESS_HYDRATION_WARNING) ; else if (propKey === AUTOFOCUS) ; else if (registrationNameModules.hasOwnProperty(propKey)) {
5946 if (nextProp != null) {
5947 if ( typeof nextProp !== 'function') {
5948 warnForInvalidEventListener(propKey, nextProp);
5949 }
5950
5951 ensureListeningTo(rootContainerElement, propKey);
5952 }
5953 } else if (nextProp != null) {
5954 setValueForProperty(domElement, propKey, nextProp, isCustomComponentTag);
5955 }
5956 }
5957 }
5958
5959 function updateDOMProperties(domElement, updatePayload, wasCustomComponentTag, isCustomComponentTag) {
5960 // 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