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

Function setInitialDOMProperties

code/new-context-api/public/app.js:15492–15542  ·  view source on GitHub ↗
(tag, domElement, rootContainerElement, nextProps, isCustomComponentTag)

Source from the content-addressed store, hash-verified

15490}
15491
15492function setInitialDOMProperties(tag, domElement, rootContainerElement, nextProps, isCustomComponentTag) {
15493 for (var propKey in nextProps) {
15494 if (!nextProps.hasOwnProperty(propKey)) {
15495 continue;
15496 }
15497 var nextProp = nextProps[propKey];
15498 if (propKey === STYLE) {
15499 {
15500 if (nextProp) {
15501 // Freeze the next style object so that we can assume it won't be
15502 // mutated. We have already warned for this in the past.
15503 Object.freeze(nextProp);
15504 }
15505 }
15506 // Relies on `updateStylesByID` not mutating `styleUpdates`.
15507 setValueForStyles(domElement, nextProp, getStack);
15508 } else if (propKey === DANGEROUSLY_SET_INNER_HTML) {
15509 var nextHtml = nextProp ? nextProp[HTML] : undefined;
15510 if (nextHtml != null) {
15511 setInnerHTML(domElement, nextHtml);
15512 }
15513 } else if (propKey === CHILDREN) {
15514 if (typeof nextProp === 'string') {
15515 // Avoid setting initial textContent when the text is empty. In IE11 setting
15516 // textContent on a <textarea> will cause the placeholder to not
15517 // show within the <textarea> until it has been focused and blurred again.
15518 // https://github.com/facebook/react/issues/6731#issuecomment-254874553
15519 var canSetTextContent = tag !== 'textarea' || nextProp !== '';
15520 if (canSetTextContent) {
15521 setTextContent(domElement, nextProp);
15522 }
15523 } else if (typeof nextProp === 'number') {
15524 setTextContent(domElement, '' + nextProp);
15525 }
15526 } else if (propKey === SUPPRESS_CONTENT_EDITABLE_WARNING || propKey === SUPPRESS_HYDRATION_WARNING$1) {
15527 // Noop
15528 } else if (propKey === AUTOFOCUS) {
15529 // We polyfill it separately on the client during commit.
15530 // We blacklist it here rather than in the property list because we emit it in SSR.
15531 } else if (registrationNameModules.hasOwnProperty(propKey)) {
15532 if (nextProp != null) {
15533 if (true && typeof nextProp !== 'function') {
15534 warnForInvalidEventListener(propKey, nextProp);
15535 }
15536 ensureListeningTo(rootContainerElement, propKey);
15537 }
15538 } else if (nextProp != null) {
15539 setValueForProperty(domElement, propKey, nextProp, isCustomComponentTag);
15540 }
15541 }
15542}
15543
15544function updateDOMProperties(domElement, updatePayload, wasCustomComponentTag, isCustomComponentTag) {
15545 // 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