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

Function setInitialDOMProperties

code/communication/public/app.js:16166–16216  ·  view source on GitHub ↗
(tag, domElement, rootContainerElement, nextProps, isCustomComponentTag)

Source from the content-addressed store, hash-verified

16164}
16165
16166function setInitialDOMProperties(tag, domElement, rootContainerElement, nextProps, isCustomComponentTag) {
16167 for (var propKey in nextProps) {
16168 if (!nextProps.hasOwnProperty(propKey)) {
16169 continue;
16170 }
16171 var nextProp = nextProps[propKey];
16172 if (propKey === STYLE) {
16173 {
16174 if (nextProp) {
16175 // Freeze the next style object so that we can assume it won't be
16176 // mutated. We have already warned for this in the past.
16177 Object.freeze(nextProp);
16178 }
16179 }
16180 // Relies on `updateStylesByID` not mutating `styleUpdates`.
16181 setValueForStyles(domElement, nextProp, getStack);
16182 } else if (propKey === DANGEROUSLY_SET_INNER_HTML) {
16183 var nextHtml = nextProp ? nextProp[HTML] : undefined;
16184 if (nextHtml != null) {
16185 setInnerHTML(domElement, nextHtml);
16186 }
16187 } else if (propKey === CHILDREN) {
16188 if (typeof nextProp === 'string') {
16189 // Avoid setting initial textContent when the text is empty. In IE11 setting
16190 // textContent on a <textarea> will cause the placeholder to not
16191 // show within the <textarea> until it has been focused and blurred again.
16192 // https://github.com/facebook/react/issues/6731#issuecomment-254874553
16193 var canSetTextContent = tag !== 'textarea' || nextProp !== '';
16194 if (canSetTextContent) {
16195 setTextContent(domElement, nextProp);
16196 }
16197 } else if (typeof nextProp === 'number') {
16198 setTextContent(domElement, '' + nextProp);
16199 }
16200 } else if (propKey === SUPPRESS_CONTENT_EDITABLE_WARNING || propKey === SUPPRESS_HYDRATION_WARNING$1) {
16201 // Noop
16202 } else if (propKey === AUTOFOCUS) {
16203 // We polyfill it separately on the client during commit.
16204 // We blacklist it here rather than in the property list because we emit it in SSR.
16205 } else if (registrationNameModules.hasOwnProperty(propKey)) {
16206 if (nextProp != null) {
16207 if (true && typeof nextProp !== 'function') {
16208 warnForInvalidEventListener(propKey, nextProp);
16209 }
16210 ensureListeningTo(rootContainerElement, propKey);
16211 }
16212 } else if (nextProp != null) {
16213 setValueForProperty(domElement, propKey, nextProp, isCustomComponentTag);
16214 }
16215 }
16216}
16217
16218function updateDOMProperties(domElement, updatePayload, wasCustomComponentTag, isCustomComponentTag) {
16219 // 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