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

Function setInitialDOMProperties

code/third-party/public/app.js:15364–15414  ·  view source on GitHub ↗
(tag, domElement, rootContainerElement, nextProps, isCustomComponentTag)

Source from the content-addressed store, hash-verified

15362}
15363
15364function setInitialDOMProperties(tag, domElement, rootContainerElement, nextProps, isCustomComponentTag) {
15365 for (var propKey in nextProps) {
15366 if (!nextProps.hasOwnProperty(propKey)) {
15367 continue;
15368 }
15369 var nextProp = nextProps[propKey];
15370 if (propKey === STYLE) {
15371 {
15372 if (nextProp) {
15373 // Freeze the next style object so that we can assume it won't be
15374 // mutated. We have already warned for this in the past.
15375 Object.freeze(nextProp);
15376 }
15377 }
15378 // Relies on `updateStylesByID` not mutating `styleUpdates`.
15379 setValueForStyles(domElement, nextProp, getStack);
15380 } else if (propKey === DANGEROUSLY_SET_INNER_HTML) {
15381 var nextHtml = nextProp ? nextProp[HTML] : undefined;
15382 if (nextHtml != null) {
15383 setInnerHTML(domElement, nextHtml);
15384 }
15385 } else if (propKey === CHILDREN) {
15386 if (typeof nextProp === 'string') {
15387 // Avoid setting initial textContent when the text is empty. In IE11 setting
15388 // textContent on a <textarea> will cause the placeholder to not
15389 // show within the <textarea> until it has been focused and blurred again.
15390 // https://github.com/facebook/react/issues/6731#issuecomment-254874553
15391 var canSetTextContent = tag !== 'textarea' || nextProp !== '';
15392 if (canSetTextContent) {
15393 setTextContent(domElement, nextProp);
15394 }
15395 } else if (typeof nextProp === 'number') {
15396 setTextContent(domElement, '' + nextProp);
15397 }
15398 } else if (propKey === SUPPRESS_CONTENT_EDITABLE_WARNING || propKey === SUPPRESS_HYDRATION_WARNING$1) {
15399 // Noop
15400 } else if (propKey === AUTOFOCUS) {
15401 // We polyfill it separately on the client during commit.
15402 // We blacklist it here rather than in the property list because we emit it in SSR.
15403 } else if (registrationNameModules.hasOwnProperty(propKey)) {
15404 if (nextProp != null) {
15405 if (true && typeof nextProp !== 'function') {
15406 warnForInvalidEventListener(propKey, nextProp);
15407 }
15408 ensureListeningTo(rootContainerElement, propKey);
15409 }
15410 } else if (nextProp != null) {
15411 setValueForProperty(domElement, propKey, nextProp, isCustomComponentTag);
15412 }
15413 }
15414}
15415
15416function updateDOMProperties(domElement, updatePayload, wasCustomComponentTag, isCustomComponentTag) {
15417 // 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