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

Function setInitialDOMProperties

code/composition/public/app.js:16269–16319  ·  view source on GitHub ↗
(tag, domElement, rootContainerElement, nextProps, isCustomComponentTag)

Source from the content-addressed store, hash-verified

16267}
16268
16269function setInitialDOMProperties(tag, domElement, rootContainerElement, nextProps, isCustomComponentTag) {
16270 for (var propKey in nextProps) {
16271 if (!nextProps.hasOwnProperty(propKey)) {
16272 continue;
16273 }
16274 var nextProp = nextProps[propKey];
16275 if (propKey === STYLE) {
16276 {
16277 if (nextProp) {
16278 // Freeze the next style object so that we can assume it won't be
16279 // mutated. We have already warned for this in the past.
16280 Object.freeze(nextProp);
16281 }
16282 }
16283 // Relies on `updateStylesByID` not mutating `styleUpdates`.
16284 setValueForStyles(domElement, nextProp, getStack);
16285 } else if (propKey === DANGEROUSLY_SET_INNER_HTML) {
16286 var nextHtml = nextProp ? nextProp[HTML] : undefined;
16287 if (nextHtml != null) {
16288 setInnerHTML(domElement, nextHtml);
16289 }
16290 } else if (propKey === CHILDREN) {
16291 if (typeof nextProp === 'string') {
16292 // Avoid setting initial textContent when the text is empty. In IE11 setting
16293 // textContent on a <textarea> will cause the placeholder to not
16294 // show within the <textarea> until it has been focused and blurred again.
16295 // https://github.com/facebook/react/issues/6731#issuecomment-254874553
16296 var canSetTextContent = tag !== 'textarea' || nextProp !== '';
16297 if (canSetTextContent) {
16298 setTextContent(domElement, nextProp);
16299 }
16300 } else if (typeof nextProp === 'number') {
16301 setTextContent(domElement, '' + nextProp);
16302 }
16303 } else if (propKey === SUPPRESS_CONTENT_EDITABLE_WARNING || propKey === SUPPRESS_HYDRATION_WARNING$1) {
16304 // Noop
16305 } else if (propKey === AUTOFOCUS) {
16306 // We polyfill it separately on the client during commit.
16307 // We blacklist it here rather than in the property list because we emit it in SSR.
16308 } else if (registrationNameModules.hasOwnProperty(propKey)) {
16309 if (nextProp != null) {
16310 if (true && typeof nextProp !== 'function') {
16311 warnForInvalidEventListener(propKey, nextProp);
16312 }
16313 ensureListeningTo(rootContainerElement, propKey);
16314 }
16315 } else if (nextProp != null) {
16316 setValueForProperty(domElement, propKey, nextProp, isCustomComponentTag);
16317 }
16318 }
16319}
16320
16321function updateDOMProperties(domElement, updatePayload, wasCustomComponentTag, isCustomComponentTag) {
16322 // 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