MCPcopy Create free account
hub / github.com/krasimir/react-in-patterns / setInitialDOMProperties

Function setInitialDOMProperties

code/styling/public/app.js:16131–16181  ·  view source on GitHub ↗
(tag, domElement, rootContainerElement, nextProps, isCustomComponentTag)

Source from the content-addressed store, hash-verified

16129}
16130
16131function setInitialDOMProperties(tag, domElement, rootContainerElement, nextProps, isCustomComponentTag) {
16132 for (var propKey in nextProps) {
16133 if (!nextProps.hasOwnProperty(propKey)) {
16134 continue;
16135 }
16136 var nextProp = nextProps[propKey];
16137 if (propKey === STYLE) {
16138 {
16139 if (nextProp) {
16140 // Freeze the next style object so that we can assume it won't be
16141 // mutated. We have already warned for this in the past.
16142 Object.freeze(nextProp);
16143 }
16144 }
16145 // Relies on `updateStylesByID` not mutating `styleUpdates`.
16146 setValueForStyles(domElement, nextProp, getStack);
16147 } else if (propKey === DANGEROUSLY_SET_INNER_HTML) {
16148 var nextHtml = nextProp ? nextProp[HTML] : undefined;
16149 if (nextHtml != null) {
16150 setInnerHTML(domElement, nextHtml);
16151 }
16152 } else if (propKey === CHILDREN) {
16153 if (typeof nextProp === 'string') {
16154 // Avoid setting initial textContent when the text is empty. In IE11 setting
16155 // textContent on a <textarea> will cause the placeholder to not
16156 // show within the <textarea> until it has been focused and blurred again.
16157 // https://github.com/facebook/react/issues/6731#issuecomment-254874553
16158 var canSetTextContent = tag !== 'textarea' || nextProp !== '';
16159 if (canSetTextContent) {
16160 setTextContent(domElement, nextProp);
16161 }
16162 } else if (typeof nextProp === 'number') {
16163 setTextContent(domElement, '' + nextProp);
16164 }
16165 } else if (propKey === SUPPRESS_CONTENT_EDITABLE_WARNING || propKey === SUPPRESS_HYDRATION_WARNING$1) {
16166 // Noop
16167 } else if (propKey === AUTOFOCUS) {
16168 // We polyfill it separately on the client during commit.
16169 // We blacklist it here rather than in the property list because we emit it in SSR.
16170 } else if (registrationNameModules.hasOwnProperty(propKey)) {
16171 if (nextProp != null) {
16172 if (true && typeof nextProp !== 'function') {
16173 warnForInvalidEventListener(propKey, nextProp);
16174 }
16175 ensureListeningTo(rootContainerElement, propKey);
16176 }
16177 } else if (nextProp != null) {
16178 setValueForProperty(domElement, propKey, nextProp, isCustomComponentTag);
16179 }
16180 }
16181}
16182
16183function updateDOMProperties(domElement, updatePayload, wasCustomComponentTag, isCustomComponentTag) {
16184 // TODO: Handle wasCustomComponentTag

Callers 1

setInitialProperties$1Function · 0.70

Calls 4

setValueForStylesFunction · 0.70
setTextContentFunction · 0.70
ensureListeningToFunction · 0.70
setValueForPropertyFunction · 0.70

Tested by

no test coverage detected