diff --git a/compiled/facebook-www/REVISION b/compiled/facebook-www/REVISION index ee73d4c05aa95..a55b7b1397de3 100644 --- a/compiled/facebook-www/REVISION +++ b/compiled/facebook-www/REVISION @@ -1 +1 @@ -2788d0d8dd95ed57e2dbb148853fe69010e992fe +6bd53a5bdfe24d9a70819c4eba40b488e62900cd diff --git a/compiled/facebook-www/React-dev.modern.js b/compiled/facebook-www/React-dev.modern.js index 3ca572e53db01..2065ca9edcaea 100644 --- a/compiled/facebook-www/React-dev.modern.js +++ b/compiled/facebook-www/React-dev.modern.js @@ -27,7 +27,7 @@ if ( } "use strict"; -var ReactVersion = "18.3.0-www-modern-f236d170"; +var ReactVersion = "18.3.0-www-modern-724bb919"; // ATTENTION // When adding new symbols to this file, diff --git a/compiled/facebook-www/ReactART-dev.classic.js b/compiled/facebook-www/ReactART-dev.classic.js index 3767cfd623f49..6413b726a89d1 100644 --- a/compiled/facebook-www/ReactART-dev.classic.js +++ b/compiled/facebook-www/ReactART-dev.classic.js @@ -69,7 +69,7 @@ function _assertThisInitialized(self) { return self; } -var ReactVersion = "18.3.0-www-classic-dd1bbdc2"; +var ReactVersion = "18.3.0-www-classic-5ea6b0b1"; var LegacyRoot = 0; var ConcurrentRoot = 1; diff --git a/compiled/facebook-www/ReactDOMTesting-dev.classic.js b/compiled/facebook-www/ReactDOMTesting-dev.classic.js index da7f7d4e959cb..8f2654e8ed9d7 100644 --- a/compiled/facebook-www/ReactDOMTesting-dev.classic.js +++ b/compiled/facebook-www/ReactDOMTesting-dev.classic.js @@ -21,22 +21,58 @@ var React = require("react"); var assign = Object.assign; -var debugRenderPhaseSideEffectsForStrictMode = false; -var enableSchedulingProfiler = false; -var enableProfilerTimer = false; -var disableCommentsAsDOMContainers = true; -var enableSuspenseCallback = true; -var enableClientRenderFallbackOnTextMismatch = true; +// Re-export dynamic flags from the www version. +var dynamicFeatureFlags = require("ReactFeatureFlags"); + +var disableInputAttributeSyncing = + dynamicFeatureFlags.disableInputAttributeSyncing, + enableTrustedTypesIntegration = + dynamicFeatureFlags.enableTrustedTypesIntegration, + replayFailedUnitOfWorkWithInvokeGuardedCallback = + dynamicFeatureFlags.replayFailedUnitOfWorkWithInvokeGuardedCallback, + enableFilterEmptyStringAttributesDOM = + dynamicFeatureFlags.enableFilterEmptyStringAttributesDOM, + enableLegacyFBSupport = dynamicFeatureFlags.enableLegacyFBSupport, + deferRenderPhaseUpdateToNextBatch = + dynamicFeatureFlags.deferRenderPhaseUpdateToNextBatch, + enableDebugTracing = dynamicFeatureFlags.enableDebugTracing, + skipUnmountedBoundaries = dynamicFeatureFlags.skipUnmountedBoundaries, + enableUseRefAccessWarning = dynamicFeatureFlags.enableUseRefAccessWarning, + disableNativeComponentFrames = + dynamicFeatureFlags.disableNativeComponentFrames, + disableSchedulerTimeoutInWorkLoop = + dynamicFeatureFlags.disableSchedulerTimeoutInWorkLoop, + enableLazyContextPropagation = + dynamicFeatureFlags.enableLazyContextPropagation, + enableUnifiedSyncLane = dynamicFeatureFlags.enableUnifiedSyncLane, + enableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay = + dynamicFeatureFlags.enableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay, + enableTransitionTracing = dynamicFeatureFlags.enableTransitionTracing, + enableCustomElementPropertySupport = + dynamicFeatureFlags.enableCustomElementPropertySupport; // On WWW, false is used for a new modern build. +var enableProfilerTimer = true; +var enableProfilerCommitHooks = true; +var enableProfilerNestedUpdatePhase = true; +var enableProfilerNestedUpdateScheduledHook = + dynamicFeatureFlags.enableProfilerNestedUpdateScheduledHook; var createRootStrictEffectsByDefault = false; -var enableLazyContextPropagation = false; -var enableLegacyHidden = false; -var enableCustomElementPropertySupport = false; +var enableClientRenderFallbackOnTextMismatch = false; // Logs additional User Timing API marks for use with an experimental profiling tool. + +var enableSchedulingProfiler = dynamicFeatureFlags.enableSchedulingProfiler; // Note: we'll want to remove this when we to userland implementation. +var enableSuspenseCallback = true; // This refers to a WWW module. var warningWWW = require("warning"); + +var suppressWarning = false; +function setSuppressWarning(newSuppressWarning) { + { + suppressWarning = newSuppressWarning; + } +} function warn(format) { { - { + if (!suppressWarning) { for ( var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), @@ -53,7 +89,7 @@ function warn(format) { } function error(format) { { - { + if (!suppressWarning) { for ( var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), @@ -171,6 +207,7 @@ var REACT_TRACING_MARKER_TYPE = Symbol.for("react.tracing_marker"); var REACT_SERVER_CONTEXT_DEFAULT_VALUE_NOT_LOADED = Symbol.for( "react.default_value" ); +var REACT_MEMO_CACHE_SENTINEL = Symbol.for("react.memo_cache_sentinel"); var MAYBE_ITERATOR_SYMBOL = Symbol.iterator; var FAUX_ITERATOR_SYMBOL = "@@iterator"; function getIteratorFn(maybeIterable) { @@ -251,6 +288,13 @@ function getComponentNameFromType(type) { case REACT_CACHE_TYPE: { return "Cache"; } + + // eslint-disable-next-line no-fallthrough + + case REACT_TRACING_MARKER_TYPE: + if (enableTransitionTracing) { + return "TracingMarker"; + } } if (typeof type === "object") { @@ -397,6 +441,10 @@ function getComponentNameFromFiber(fiber) { } break; + + case LegacyHiddenComponent: { + return "LegacyHidden"; + } } return null; @@ -470,6 +518,12 @@ var ShouldCapture = var ForceUpdateForLegacySuspense = /* */ 131072; +var DidPropagateContext = + /* */ + 262144; +var NeedsPropagation = + /* */ + 524288; var Forked = /* */ 1048576; // Static tags describe aspects of a fiber that are not specific to a render, @@ -1436,10 +1490,43 @@ function shouldRemoveAttribute( } if (isCustomComponentTag) { + if (enableCustomElementPropertySupport) { + if (value === false) { + return true; + } + } + return false; } if (propertyInfo !== null) { + if (enableFilterEmptyStringAttributesDOM) { + if (propertyInfo.removeEmptyString && value === "") { + { + if (name === "src") { + error( + 'An empty string ("") was passed to the %s attribute. ' + + "This may cause the browser to download the whole page again over the network. " + + "To fix this, either do not render the element at all " + + "or pass null to %s instead of an empty string.", + name, + name + ); + } else { + error( + 'An empty string ("") was passed to the %s attribute. ' + + "To fix this, either do not render the element at all " + + "or pass null to %s instead of an empty string.", + name, + name + ); + } + } + + return true; + } + } + switch (propertyInfo.type) { case BOOLEAN: return !value; @@ -1500,6 +1587,10 @@ var reservedProps = [ "style" ]; +if (enableCustomElementPropertySupport) { + reservedProps.push("innerText", "textContent"); +} + reservedProps.forEach(function (name) { // $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions properties[name] = new PropertyInfoRecord( @@ -1988,6 +2079,12 @@ function getValueForAttribute(node, name, expected, isCustomComponentTag) { var value = node.getAttribute(name); + if (enableCustomElementPropertySupport) { + if (isCustomComponentTag && value === "") { + return true; + } + } + { checkAttributeStringCoercion(expected, name); } @@ -2014,10 +2111,57 @@ function setValueForProperty(node, name, value, isCustomComponentTag) { return; } + if ( + enableCustomElementPropertySupport && + isCustomComponentTag && + name[0] === "o" && + name[1] === "n" + ) { + var eventName = name.replace(/Capture$/, ""); + var useCapture = name !== eventName; + eventName = eventName.slice(2); + var prevProps = getFiberCurrentPropsFromNode(node); + var prevValue = prevProps != null ? prevProps[name] : null; + + if (typeof prevValue === "function") { + node.removeEventListener(eventName, prevValue, useCapture); + } + + if (typeof value === "function") { + if (typeof prevValue !== "function" && prevValue !== null) { + // If we previously assigned a non-function type into this node, then + // remove it when switching to event listener mode. + if (name in node) { + node[name] = null; + } else if (node.hasAttribute(name)) { + node.removeAttribute(name); + } + } // $FlowFixMe value can't be casted to EventListener. + + node.addEventListener(eventName, value, useCapture); + return; + } + } + + if ( + enableCustomElementPropertySupport && + isCustomComponentTag && + name in node + ) { + node[name] = value; + return; + } + if (shouldRemoveAttribute(name, value, propertyInfo, isCustomComponentTag)) { value = null; } + if (enableCustomElementPropertySupport) { + if (isCustomComponentTag && value === true) { + value = ""; + } + } // If the prop isn't in the special list, treat it as a simple attribute. + if (isCustomComponentTag || propertyInfo === null) { if (isAttributeNameSafe(name)) { var _attributeName = name; @@ -2029,7 +2173,10 @@ function setValueForProperty(node, name, value, isCustomComponentTag) { checkAttributeStringCoercion(value, name); } - node.setAttribute(_attributeName, "" + value); + node.setAttribute( + _attributeName, + enableTrustedTypesIntegration ? value : "" + value + ); } } @@ -2069,7 +2216,9 @@ function setValueForProperty(node, name, value, isCustomComponentTag) { } else { // `setAttribute` with objects becomes only `[object]` in IE8/9, // ('' + value) makes it output the correct toString()-value. - { + if (enableTrustedTypesIntegration) { + attributeValue = value; + } else { { checkAttributeStringCoercion(value, attributeName); } @@ -2208,13 +2357,13 @@ var reentry = false; var componentFrameCache; { - var PossiblyWeakMap$1 = typeof WeakMap === "function" ? WeakMap : Map; - componentFrameCache = new PossiblyWeakMap$1(); + var PossiblyWeakMap$2 = typeof WeakMap === "function" ? WeakMap : Map; + componentFrameCache = new PossiblyWeakMap$2(); } function describeNativeComponentFrame(fn, construct) { // If something asked for a stack inside a fake render, it should get ignored. - if (!fn || reentry) { + if (disableNativeComponentFrames || !fn || reentry) { return ""; } @@ -2929,7 +3078,14 @@ function updateWrapper$1(element, props) { return; } - { + if (disableInputAttributeSyncing) { + // When not syncing the value attribute, React only assigns a new value + // whenever the defaultValue React prop has changed. When not present, + // React does nothing + if (props.hasOwnProperty("defaultValue")) { + setDefaultValue(node, props.type, getToStringValue(props.defaultValue)); + } + } else { // When syncing the value attribute, the value comes from a cascade of // properties: // 1. The value React property @@ -2942,7 +3098,16 @@ function updateWrapper$1(element, props) { } } - { + if (disableInputAttributeSyncing) { + // When not syncing the checked attribute, the attribute is directly + // controllable from the defaultValue React property. It needs to be + // updated as new props come in. + if (props.defaultChecked == null) { + node.removeAttribute("checked"); + } else { + node.defaultChecked = !!props.defaultChecked; + } + } else { // When syncing the checked attribute, it only changes when it needs // to be removed, such as transitioning from a checkbox into a text input if (props.checked == null && props.defaultChecked != null) { @@ -2967,7 +3132,24 @@ function postMountWrapper$3(element, props, isHydrating) { // from being lost during SSR hydration. if (!isHydrating) { - { + if (disableInputAttributeSyncing) { + var value = getToStringValue(props.value); // When not syncing the value attribute, the value property points + // directly to the React prop. Only assign it if it exists. + + if (value != null) { + // Always assign on buttons so that it is possible to assign an + // empty string to clear button text. + // + // Otherwise, do not re-assign the value property if is empty. This + // potentially avoids a DOM write and prevents Firefox (~60.0.1) from + // prematurely marking required inputs as invalid. Equality is compared + // to the current value in case the browser provided value is not an + // empty string. + if (isButton || value !== node.value) { + node.value = toString(value); + } + } + } else { // When syncing the value attribute, the value property should use // the wrapperState._initialValue property. This uses: // @@ -2980,7 +3162,15 @@ function postMountWrapper$3(element, props, isHydrating) { } } - { + if (disableInputAttributeSyncing) { + // When not syncing the value attribute, assign the value attribute + // directly from the defaultValue React property (when present) + var defaultValue = getToStringValue(props.defaultValue); + + if (defaultValue != null) { + node.defaultValue = toString(defaultValue); + } + } else { // Otherwise, the value attribute is synchronized to the property, // so we assign defaultValue to the same thing as the value property // assignment step above. @@ -2998,7 +3188,22 @@ function postMountWrapper$3(element, props, isHydrating) { node.name = ""; } - { + if (disableInputAttributeSyncing) { + // When not syncing the checked attribute, the checked property + // never gets assigned. It must be manually set. We don't want + // to do this when hydrating so that existing user input isn't + // modified + if (!isHydrating) { + updateChecked(element, props); + } // Only assign the checked attribute if it is defined. This saves + // a DOM write when controlling the checked attribute isn't needed + // (text inputs, submit/reset) + + if (props.hasOwnProperty("defaultChecked")) { + node.defaultChecked = !node.defaultChecked; + node.defaultChecked = !!props.defaultChecked; + } + } else { // When syncing the checked attribute, both the checked property and // attribute are assigned at the same time using defaultChecked. This uses: // @@ -3559,6 +3764,23 @@ var reusableSVGContainer; var setInnerHTML = createMicrosoftUnsafeLocalFunction(function (node, html) { if (node.namespaceURI === SVG_NAMESPACE) { + { + if (enableTrustedTypesIntegration) { + // TODO: reconsider the text of this warning and when it should show + // before enabling the feature flag. + if (typeof trustedTypes !== "undefined") { + error( + "Using 'dangerouslySetInnerHTML' in an svg element with " + + "Trusted Types enabled in an Internet Explorer will cause " + + "the trusted value to be converted to string. Assigning string " + + "to 'innerHTML' will throw an error if Trusted Types are enforced. " + + "You can try to wrap your svg element inside a div and use 'dangerouslySetInnerHTML' " + + "on the enclosing div instead." + ); + } + } + } + if (!("innerHTML" in node)) { // IE does not have innerHTML for SVG nodes, so instead we inject the // new markup in a temp node and then move the child nodes across into @@ -5298,6 +5520,7 @@ function validateProperties(type, props, eventRegistry) { } var didWarnInvalidHydration = false; +var didWarnScriptTags = false; var DANGEROUSLY_SET_INNER_HTML = "dangerouslySetInnerHTML"; var SUPPRESS_CONTENT_EDITABLE_WARNING = "suppressContentEditableWarning"; var SUPPRESS_HYDRATION_WARNING$1 = "suppressHydrationWarning"; @@ -5585,6 +5808,19 @@ function createPotentiallyInlineScriptElement(ownerDocument) { // set to true and it does not execute var div = ownerDocument.createElement("div"); + { + if (enableTrustedTypesIntegration && !didWarnScriptTags) { + error( + "Encountered a script tag while rendering React component. " + + "Scripts inside React components are never executed when rendering " + + "on the client. Consider using template tag instead " + + "(https://developer.mozilla.org/en-US/docs/Web/HTML/Element/template)." + ); + + didWarnScriptTags = true; + } + } + div.innerHTML = "