From 9b26db059bad74d47ad3d6bd942695639a4f3dec Mon Sep 17 00:00:00 2001 From: sebmarkbage Date: Wed, 15 Mar 2023 01:06:18 +0000 Subject: [PATCH] Avoid meta programming to initialize functions in module scope (#26388) I'm trying to get rid of all meta programming in the module scope so that closure can do a better job figuring out cyclic dependencies and ability to reorder. This is converting a lot of the patterns that assign functions conditionally to using function declarations instead. ``` let fn; if (__DEV__) { fn = function() { ... }; } ``` -> ``` function fn() { if (__DEV__) { ... } } ``` DiffTrain build for [d310d654a7c7aab6c8213da84ef36dfba82711b0](https://github.com/facebook/react/commit/d310d654a7c7aab6c8213da84ef36dfba82711b0) --- .../facebook-www/JSXDEVRuntime-dev.classic.js | 4 +- .../facebook-www/JSXDEVRuntime-dev.modern.js | 4 +- compiled/facebook-www/REVISION | 2 +- compiled/facebook-www/React-dev.classic.js | 10 +- compiled/facebook-www/React-dev.modern.js | 10 +- compiled/facebook-www/ReactART-dev.classic.js | 79 +- compiled/facebook-www/ReactART-dev.modern.js | 79 +- compiled/facebook-www/ReactART-prod.modern.js | 4 +- compiled/facebook-www/ReactDOM-dev.classic.js | 941 +++++++++--------- compiled/facebook-www/ReactDOM-dev.modern.js | 941 +++++++++--------- .../facebook-www/ReactDOM-prod.classic.js | 70 +- compiled/facebook-www/ReactDOM-prod.modern.js | 70 +- .../ReactDOM-profiling.classic.js | 56 +- .../facebook-www/ReactDOM-profiling.modern.js | 56 +- .../ReactDOMServer-dev.classic.js | 117 ++- .../facebook-www/ReactDOMServer-dev.modern.js | 117 ++- .../ReactDOMServerStreaming-dev.modern.js | 115 ++- .../ReactDOMTesting-dev.classic.js | 941 +++++++++--------- .../ReactDOMTesting-dev.modern.js | 941 +++++++++--------- .../ReactDOMTesting-prod.classic.js | 70 +- .../ReactDOMTesting-prod.modern.js | 70 +- .../ReactTestRenderer-dev.classic.js | 79 +- .../ReactTestRenderer-dev.modern.js | 79 +- .../ReactTestUtils-dev.classic.js | 18 +- .../facebook-www/ReactTestUtils-dev.modern.js | 18 +- 25 files changed, 2392 insertions(+), 2499 deletions(-) diff --git a/compiled/facebook-www/JSXDEVRuntime-dev.classic.js b/compiled/facebook-www/JSXDEVRuntime-dev.classic.js index b9bafc9f8a87c..272fede79801b 100644 --- a/compiled/facebook-www/JSXDEVRuntime-dev.classic.js +++ b/compiled/facebook-www/JSXDEVRuntime-dev.classic.js @@ -941,7 +941,7 @@ function defineRefPropWarningGetter(props, displayName) { * @internal */ -var ReactElement = function (type, key, ref, self, source, owner, props) { +function ReactElement(type, key, ref, self, source, owner, props) { var element = { // This tag allows us to uniquely identify this as a React Element $$typeof: REACT_ELEMENT_TYPE, @@ -993,7 +993,7 @@ var ReactElement = function (type, key, ref, self, source, owner, props) { } return element; -}; +} /** * https://github.com/reactjs/rfcs/pull/107 * @param {*} type diff --git a/compiled/facebook-www/JSXDEVRuntime-dev.modern.js b/compiled/facebook-www/JSXDEVRuntime-dev.modern.js index e9f61bd91c579..28c9e1396b5b2 100644 --- a/compiled/facebook-www/JSXDEVRuntime-dev.modern.js +++ b/compiled/facebook-www/JSXDEVRuntime-dev.modern.js @@ -941,7 +941,7 @@ function defineRefPropWarningGetter(props, displayName) { * @internal */ -var ReactElement = function (type, key, ref, self, source, owner, props) { +function ReactElement(type, key, ref, self, source, owner, props) { var element = { // This tag allows us to uniquely identify this as a React Element $$typeof: REACT_ELEMENT_TYPE, @@ -993,7 +993,7 @@ var ReactElement = function (type, key, ref, self, source, owner, props) { } return element; -}; +} /** * https://github.com/reactjs/rfcs/pull/107 * @param {*} type diff --git a/compiled/facebook-www/REVISION b/compiled/facebook-www/REVISION index a55b7b1397de3..219cda440ac83 100644 --- a/compiled/facebook-www/REVISION +++ b/compiled/facebook-www/REVISION @@ -1 +1 @@ -6bd53a5bdfe24d9a70819c4eba40b488e62900cd +d310d654a7c7aab6c8213da84ef36dfba82711b0 diff --git a/compiled/facebook-www/React-dev.classic.js b/compiled/facebook-www/React-dev.classic.js index 41af6c6048785..4bac8b25d41fc 100644 --- a/compiled/facebook-www/React-dev.classic.js +++ b/compiled/facebook-www/React-dev.classic.js @@ -27,7 +27,7 @@ if ( } "use strict"; -var ReactVersion = "18.3.0-www-classic-96f33629"; +var ReactVersion = "18.3.0-www-classic-e762d1a9"; // ATTENTION // When adding new symbols to this file, @@ -756,7 +756,7 @@ function warnIfStringRefCannotBeAutoConverted$1(config) { * @internal */ -var ReactElement$1 = function (type, key, ref, self, source, owner, props) { +function ReactElement$1(type, key, ref, self, source, owner, props) { var element = { // This tag allows us to uniquely identify this as a React Element $$typeof: REACT_ELEMENT_TYPE, @@ -808,7 +808,7 @@ var ReactElement$1 = function (type, key, ref, self, source, owner, props) { } return element; -}; +} /** * Create and return a new ReactElement of the given type. * See https://reactjs.org/docs/react-api.html#createelement @@ -3574,7 +3574,7 @@ function defineRefPropWarningGetter(props, displayName) { * @internal */ -var ReactElement = function (type, key, ref, self, source, owner, props) { +function ReactElement(type, key, ref, self, source, owner, props) { var element = { // This tag allows us to uniquely identify this as a React Element $$typeof: REACT_ELEMENT_TYPE, @@ -3626,7 +3626,7 @@ var ReactElement = function (type, key, ref, self, source, owner, props) { } return element; -}; +} /** * https://github.com/reactjs/rfcs/pull/107 * @param {*} type diff --git a/compiled/facebook-www/React-dev.modern.js b/compiled/facebook-www/React-dev.modern.js index 2065ca9edcaea..6b5154eef5b4b 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-724bb919"; +var ReactVersion = "18.3.0-www-modern-9bafe2f6"; // ATTENTION // When adding new symbols to this file, @@ -756,7 +756,7 @@ function warnIfStringRefCannotBeAutoConverted$1(config) { * @internal */ -var ReactElement$1 = function (type, key, ref, self, source, owner, props) { +function ReactElement$1(type, key, ref, self, source, owner, props) { var element = { // This tag allows us to uniquely identify this as a React Element $$typeof: REACT_ELEMENT_TYPE, @@ -808,7 +808,7 @@ var ReactElement$1 = function (type, key, ref, self, source, owner, props) { } return element; -}; +} /** * Create and return a new ReactElement of the given type. * See https://reactjs.org/docs/react-api.html#createelement @@ -3539,7 +3539,7 @@ function defineRefPropWarningGetter(props, displayName) { * @internal */ -var ReactElement = function (type, key, ref, self, source, owner, props) { +function ReactElement(type, key, ref, self, source, owner, props) { var element = { // This tag allows us to uniquely identify this as a React Element $$typeof: REACT_ELEMENT_TYPE, @@ -3591,7 +3591,7 @@ var ReactElement = function (type, key, ref, self, source, owner, props) { } return element; -}; +} /** * https://github.com/reactjs/rfcs/pull/107 * @param {*} type diff --git a/compiled/facebook-www/ReactART-dev.classic.js b/compiled/facebook-www/ReactART-dev.classic.js index 6413b726a89d1..f5da1f8b17577 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-5ea6b0b1"; +var ReactVersion = "18.3.0-www-classic-d10ee72f"; var LegacyRoot = 0; var ConcurrentRoot = 1; @@ -10978,11 +10978,10 @@ var didWarnAboutUninitializedState; var didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate; var didWarnAboutLegacyLifecyclesAndDerivedState; var didWarnAboutUndefinedDerivedState; -var warnOnUndefinedDerivedState; -var warnOnInvalidCallback; var didWarnAboutDirectlyAssigningPropsToState; var didWarnAboutContextTypeAndContextTypes; var didWarnAboutInvalidateContextType; +var didWarnOnInvalidCallback; { didWarnAboutStateAssignmentForComponent = new Set(); @@ -10993,9 +10992,30 @@ var didWarnAboutInvalidateContextType; didWarnAboutUndefinedDerivedState = new Set(); didWarnAboutContextTypeAndContextTypes = new Set(); didWarnAboutInvalidateContextType = new Set(); - var didWarnOnInvalidCallback = new Set(); + didWarnOnInvalidCallback = new Set(); // This is so gross but it's at least non-critical and can be removed if + // it causes problems. This is meant to give a nicer error message for + // ReactDOM15.unstable_renderSubtreeIntoContainer(reactDOM16Component, + // ...)) which otherwise throws a "_processChildContext is not a function" + // exception. + + Object.defineProperty(fakeInternalInstance, "_processChildContext", { + enumerable: false, + value: function () { + throw new Error( + "_processChildContext is not available in React 16+. This likely " + + "means you have multiple copies of React and are attempting to nest " + + "a React 15 tree inside a React 16 tree using " + + "unstable_renderSubtreeIntoContainer, which isn't supported. Try " + + "to make sure you have only one copy of React (and ideally, switch " + + "to ReactDOM.createPortal)." + ); + } + }); + Object.freeze(fakeInternalInstance); +} - warnOnInvalidCallback = function (callback, callerName) { +function warnOnInvalidCallback(callback, callerName) { + { if (callback === null || typeof callback === "function") { return; } @@ -11012,9 +11032,11 @@ var didWarnAboutInvalidateContextType; callback ); } - }; + } +} - warnOnUndefinedDerivedState = function (type, partialState) { +function warnOnUndefinedDerivedState(type, partialState) { + { if (partialState === undefined) { var componentName = getComponentNameFromType(type) || "Component"; @@ -11028,26 +11050,7 @@ var didWarnAboutInvalidateContextType; ); } } - }; // This is so gross but it's at least non-critical and can be removed if - // it causes problems. This is meant to give a nicer error message for - // ReactDOM15.unstable_renderSubtreeIntoContainer(reactDOM16Component, - // ...)) which otherwise throws a "_processChildContext is not a function" - // exception. - - Object.defineProperty(fakeInternalInstance, "_processChildContext", { - enumerable: false, - value: function () { - throw new Error( - "_processChildContext is not available in React 16+. This likely " + - "means you have multiple copies of React and are attempting to nest " + - "a React 15 tree inside a React 16 tree using " + - "unstable_renderSubtreeIntoContainer, which isn't supported. Try " + - "to make sure you have only one copy of React (and ideally, switch " + - "to ReactDOM.createPortal)." - ); - } - }); - Object.freeze(fakeInternalInstance); + } } function applyDerivedStateFromProps( @@ -18854,20 +18857,10 @@ if (typeof ReactFbErrorUtils.invokeGuardedCallback !== "function") { ); } -var invokeGuardedCallbackImpl = function ( - name, - func, - context, - a, - b, - c, - d, - e, - f -) { +function invokeGuardedCallbackImpl(name, func, context, a, b, c, d, e, f) { // This will call `this.onError(err)` if an error was caught. ReactFbErrorUtils.invokeGuardedCallback.apply(this, arguments); -}; +} var hasError = false; var caughtError = null; // Used by event system to capture/rethrow the first error. @@ -18949,7 +18942,7 @@ function reportUncaughtErrorInDEV(error) { } } -var callComponentWillUnmountWithTimer = function (current, instance) { +function callComponentWillUnmountWithTimer(current, instance) { instance.props = current.memoizedProps; instance.state = current.memoizedState; @@ -18963,7 +18956,7 @@ var callComponentWillUnmountWithTimer = function (current, instance) { } else { instance.componentWillUnmount(); } -}; // Capture errors so they don't interrupt unmounting. +} // Capture errors so they don't interrupt unmounting. function safelyCallComponentWillUnmount( current, @@ -26923,10 +26916,10 @@ function FiberNode(tag, pendingProps, key, mode) { // 5) It should be easy to port this to a C struct and keep a C implementation // compatible. -var createFiber = function (tag, pendingProps, key, mode) { +function createFiber(tag, pendingProps, key, mode) { // $FlowFixMe: the shapes are exact here but Flow doesn't like constructors return new FiberNode(tag, pendingProps, key, mode); -}; +} function shouldConstruct(Component) { var prototype = Component.prototype; diff --git a/compiled/facebook-www/ReactART-dev.modern.js b/compiled/facebook-www/ReactART-dev.modern.js index 3822c63bfd2c9..d32a453e98f59 100644 --- a/compiled/facebook-www/ReactART-dev.modern.js +++ b/compiled/facebook-www/ReactART-dev.modern.js @@ -69,7 +69,7 @@ function _assertThisInitialized(self) { return self; } -var ReactVersion = "18.3.0-www-modern-1b2e7ccd"; +var ReactVersion = "18.3.0-www-modern-ee471100"; var LegacyRoot = 0; var ConcurrentRoot = 1; @@ -10734,10 +10734,9 @@ var didWarnAboutUninitializedState; var didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate; var didWarnAboutLegacyLifecyclesAndDerivedState; var didWarnAboutUndefinedDerivedState; -var warnOnUndefinedDerivedState; -var warnOnInvalidCallback; var didWarnAboutDirectlyAssigningPropsToState; var didWarnAboutInvalidateContextType; +var didWarnOnInvalidCallback; { didWarnAboutStateAssignmentForComponent = new Set(); @@ -10747,9 +10746,30 @@ var didWarnAboutInvalidateContextType; didWarnAboutDirectlyAssigningPropsToState = new Set(); didWarnAboutUndefinedDerivedState = new Set(); didWarnAboutInvalidateContextType = new Set(); - var didWarnOnInvalidCallback = new Set(); + didWarnOnInvalidCallback = new Set(); // This is so gross but it's at least non-critical and can be removed if + // it causes problems. This is meant to give a nicer error message for + // ReactDOM15.unstable_renderSubtreeIntoContainer(reactDOM16Component, + // ...)) which otherwise throws a "_processChildContext is not a function" + // exception. + + Object.defineProperty(fakeInternalInstance, "_processChildContext", { + enumerable: false, + value: function () { + throw new Error( + "_processChildContext is not available in React 16+. This likely " + + "means you have multiple copies of React and are attempting to nest " + + "a React 15 tree inside a React 16 tree using " + + "unstable_renderSubtreeIntoContainer, which isn't supported. Try " + + "to make sure you have only one copy of React (and ideally, switch " + + "to ReactDOM.createPortal)." + ); + } + }); + Object.freeze(fakeInternalInstance); +} - warnOnInvalidCallback = function (callback, callerName) { +function warnOnInvalidCallback(callback, callerName) { + { if (callback === null || typeof callback === "function") { return; } @@ -10766,9 +10786,11 @@ var didWarnAboutInvalidateContextType; callback ); } - }; + } +} - warnOnUndefinedDerivedState = function (type, partialState) { +function warnOnUndefinedDerivedState(type, partialState) { + { if (partialState === undefined) { var componentName = getComponentNameFromType(type) || "Component"; @@ -10782,26 +10804,7 @@ var didWarnAboutInvalidateContextType; ); } } - }; // This is so gross but it's at least non-critical and can be removed if - // it causes problems. This is meant to give a nicer error message for - // ReactDOM15.unstable_renderSubtreeIntoContainer(reactDOM16Component, - // ...)) which otherwise throws a "_processChildContext is not a function" - // exception. - - Object.defineProperty(fakeInternalInstance, "_processChildContext", { - enumerable: false, - value: function () { - throw new Error( - "_processChildContext is not available in React 16+. This likely " + - "means you have multiple copies of React and are attempting to nest " + - "a React 15 tree inside a React 16 tree using " + - "unstable_renderSubtreeIntoContainer, which isn't supported. Try " + - "to make sure you have only one copy of React (and ideally, switch " + - "to ReactDOM.createPortal)." - ); - } - }); - Object.freeze(fakeInternalInstance); + } } function applyDerivedStateFromProps( @@ -18514,20 +18517,10 @@ if (typeof ReactFbErrorUtils.invokeGuardedCallback !== "function") { ); } -var invokeGuardedCallbackImpl = function ( - name, - func, - context, - a, - b, - c, - d, - e, - f -) { +function invokeGuardedCallbackImpl(name, func, context, a, b, c, d, e, f) { // This will call `this.onError(err)` if an error was caught. ReactFbErrorUtils.invokeGuardedCallback.apply(this, arguments); -}; +} var hasError = false; var caughtError = null; // Used by event system to capture/rethrow the first error. @@ -18609,7 +18602,7 @@ function reportUncaughtErrorInDEV(error) { } } -var callComponentWillUnmountWithTimer = function (current, instance) { +function callComponentWillUnmountWithTimer(current, instance) { instance.props = current.memoizedProps; instance.state = current.memoizedState; @@ -18623,7 +18616,7 @@ var callComponentWillUnmountWithTimer = function (current, instance) { } else { instance.componentWillUnmount(); } -}; // Capture errors so they don't interrupt unmounting. +} // Capture errors so they don't interrupt unmounting. function safelyCallComponentWillUnmount( current, @@ -26583,10 +26576,10 @@ function FiberNode(tag, pendingProps, key, mode) { // 5) It should be easy to port this to a C struct and keep a C implementation // compatible. -var createFiber = function (tag, pendingProps, key, mode) { +function createFiber(tag, pendingProps, key, mode) { // $FlowFixMe: the shapes are exact here but Flow doesn't like constructors return new FiberNode(tag, pendingProps, key, mode); -}; +} function shouldConstruct(Component) { var prototype = Component.prototype; diff --git a/compiled/facebook-www/ReactART-prod.modern.js b/compiled/facebook-www/ReactART-prod.modern.js index 00a3b1bbd68d6..73465e7309f95 100644 --- a/compiled/facebook-www/ReactART-prod.modern.js +++ b/compiled/facebook-www/ReactART-prod.modern.js @@ -9555,7 +9555,7 @@ var slice = Array.prototype.slice, return null; }, bundleType: 0, - version: "18.3.0-www-modern-6722015e", + version: "18.3.0-www-modern-ce2970c7", rendererPackageName: "react-art" }; var internals$jscomp$inline_1283 = { @@ -9586,7 +9586,7 @@ var internals$jscomp$inline_1283 = { scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.3.0-www-modern-6722015e" + reconcilerVersion: "18.3.0-www-modern-ce2970c7" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { var hook$jscomp$inline_1284 = __REACT_DEVTOOLS_GLOBAL_HOOK__; diff --git a/compiled/facebook-www/ReactDOM-dev.classic.js b/compiled/facebook-www/ReactDOM-dev.classic.js index 315896516aa65..9f6d6acd56338 100644 --- a/compiled/facebook-www/ReactDOM-dev.classic.js +++ b/compiled/facebook-www/ReactDOM-dev.classic.js @@ -3602,33 +3602,9 @@ function getChildNamespace(parentNamespace, type) { return parentNamespace; } -/* globals MSApp */ - -/** - * Create a function which has 'unsafe' privileges (required by windows8 apps) - */ -var createMicrosoftUnsafeLocalFunction = function (func) { - if (typeof MSApp !== "undefined" && MSApp.execUnsafeLocalFunction) { - return function (arg0, arg1, arg2, arg3) { - MSApp.execUnsafeLocalFunction(function () { - return func(arg0, arg1, arg2, arg3); - }); - }; - } else { - return func; - } -}; - var reusableSVGContainer; -/** - * Set the innerHTML property of a node - * - * @param {DOMElement} node - * @param {string} html - * @internal - */ -var setInnerHTML = createMicrosoftUnsafeLocalFunction(function (node, html) { +function setInnerHTMLImpl(node, html) { if (node.namespaceURI === SVG_NAMESPACE) { { if (enableTrustedTypesIntegration) { @@ -3671,7 +3647,23 @@ var setInnerHTML = createMicrosoftUnsafeLocalFunction(function (node, html) { } node.innerHTML = html; -}); +} + +var setInnerHTML = setInnerHTMLImpl; // $FlowFixMe[cannot-resolve-name] + +if (typeof MSApp !== "undefined" && MSApp.execUnsafeLocalFunction) { + /** + * Create a function which has 'unsafe' privileges (required by windows8 apps) + */ + setInnerHTML = function (node, html) { + // $FlowFixMe[cannot-resolve-name] + return MSApp.execUnsafeLocalFunction(function () { + return setInnerHTMLImpl(node, html); + }); + }; +} + +var setInnerHTML$1 = setInnerHTML; /** * Set the textContent property of a node. For text updates, it's faster @@ -3683,7 +3675,7 @@ var setInnerHTML = createMicrosoftUnsafeLocalFunction(function (node, html) { * @internal */ -var setTextContent = function (node, text) { +function setTextContent(node, text) { if (text) { var firstChild = node.firstChild; @@ -3698,7 +3690,7 @@ var setTextContent = function (node, text) { } node.textContent = text; -}; +} // List derived from Gecko source code: // https://github.com/mozilla/gecko-dev/blob/4e638efc71/layout/style/test/property_database.js @@ -4025,27 +4017,25 @@ function hyphenateStyleName(name) { .replace(msPattern$1, "-ms-"); } -var warnValidStyle = function () {}; +// 'msTransform' is correct, but the other prefixes should be capitalized +var badVendoredStyleNamePattern = /^(?:webkit|moz|o)[A-Z]/; +var msPattern = /^-ms-/; +var hyphenPattern = /-(.)/g; // style values shouldn't contain a semicolon -{ - // 'msTransform' is correct, but the other prefixes should be capitalized - var badVendoredStyleNamePattern = /^(?:webkit|moz|o)[A-Z]/; - var msPattern = /^-ms-/; - var hyphenPattern = /-(.)/g; // style values shouldn't contain a semicolon - - var badStyleValueWithSemicolonPattern = /;\s*$/; - var warnedStyleNames = {}; - var warnedStyleValues = {}; - var warnedForNaNValue = false; - var warnedForInfinityValue = false; - - var camelize = function (string) { - return string.replace(hyphenPattern, function (_, character) { - return character.toUpperCase(); - }); - }; +var badStyleValueWithSemicolonPattern = /;\s*$/; +var warnedStyleNames = {}; +var warnedStyleValues = {}; +var warnedForNaNValue = false; +var warnedForInfinityValue = false; + +function camelize(string) { + return string.replace(hyphenPattern, function (_, character) { + return character.toUpperCase(); + }); +} - var warnHyphenatedStyleName = function (name) { +function warnHyphenatedStyleName(name) { + { if (warnedStyleNames.hasOwnProperty(name) && warnedStyleNames[name]) { return; } @@ -4059,9 +4049,11 @@ var warnValidStyle = function () {}; // is converted to lowercase `ms`. camelize(name.replace(msPattern, "ms-")) ); - }; + } +} - var warnBadVendoredStyleName = function (name) { +function warnBadVendoredStyleName(name) { + { if (warnedStyleNames.hasOwnProperty(name) && warnedStyleNames[name]) { return; } @@ -4073,9 +4065,11 @@ var warnValidStyle = function () {}; name, name.charAt(0).toUpperCase() + name.slice(1) ); - }; + } +} - var warnStyleValueWithSemicolon = function (name, value) { +function warnStyleValueWithSemicolon(name, value) { + { if (warnedStyleValues.hasOwnProperty(value) && warnedStyleValues[value]) { return; } @@ -4088,9 +4082,11 @@ var warnValidStyle = function () {}; name, value.replace(badStyleValueWithSemicolonPattern, "") ); - }; + } +} - var warnStyleValueIsNaN = function (name, value) { +function warnStyleValueIsNaN(name, value) { + { if (warnedForNaNValue) { return; } @@ -4098,9 +4094,11 @@ var warnValidStyle = function () {}; warnedForNaNValue = true; error("`NaN` is an invalid value for the `%s` css style property.", name); - }; + } +} - var warnStyleValueIsInfinity = function (name, value) { +function warnStyleValueIsInfinity(name, value) { + { if (warnedForInfinityValue) { return; } @@ -4111,9 +4109,11 @@ var warnValidStyle = function () {}; "`Infinity` is an invalid value for the `%s` css style property.", name ); - }; + } +} - warnValidStyle = function (name, value) { +function warnValidStyle(name, value) { + { if (name.indexOf("-") > -1) { warnHyphenatedStyleName(name); } else if (badVendoredStyleNamePattern.test(name)) { @@ -4124,16 +4124,14 @@ var warnValidStyle = function () {}; if (typeof value === "number") { if (isNaN(value)) { - warnStyleValueIsNaN(name, value); + warnStyleValueIsNaN(name); } else if (!isFinite(value)) { - warnStyleValueIsInfinity(name, value); + warnStyleValueIsInfinity(name); } } - }; + } } -var warnValidStyle$1 = warnValidStyle; - /** * Operations for dealing with CSS properties. */ @@ -4195,7 +4193,7 @@ function setValueForStyles(node, styles) { { if (!isCustomProperty) { - warnValidStyle$1(styleName, styles[styleName]); + warnValidStyle(styleName, styles[styleName]); } } @@ -5108,16 +5106,14 @@ function validateProperties$1(type, props) { } } -var validateProperty = function () {}; - -{ - var warnedProperties = {}; - var EVENT_NAME_REGEX = /^on./; - var INVALID_EVENT_NAME_REGEX = /^on[^A-Z]/; - var rARIA = new RegExp("^(aria)-[" + ATTRIBUTE_NAME_CHAR + "]*$"); - var rARIACamel = new RegExp("^(aria)[A-Z][" + ATTRIBUTE_NAME_CHAR + "]*$"); +var warnedProperties = {}; +var EVENT_NAME_REGEX = /^on./; +var INVALID_EVENT_NAME_REGEX = /^on[^A-Z]/; +var rARIA = new RegExp("^(aria)-[" + ATTRIBUTE_NAME_CHAR + "]*$"); +var rARIACamel = new RegExp("^(aria)[A-Z][" + ATTRIBUTE_NAME_CHAR + "]*$"); - validateProperty = function (tagName, name, value, eventRegistry) { +function validateProperty(tagName, name, value, eventRegistry) { + { if (hasOwnProperty.call(warnedProperties, name) && warnedProperties[name]) { return true; } @@ -5336,10 +5332,10 @@ var validateProperty = function () {}; } return true; - }; + } } -var warnUnknownProperties = function (type, props, eventRegistry) { +function warnUnknownProperties(type, props, eventRegistry) { { var unknownProps = []; @@ -5375,7 +5371,7 @@ var warnUnknownProperties = function (type, props, eventRegistry) { ); } } -}; +} function validateProperties(type, props, eventRegistry) { if (isCustomComponent(type, props)) { @@ -5395,12 +5391,7 @@ var CHILDREN = "children"; var STYLE$1 = "style"; var HTML = "__html"; var warnedUnknownTags; -var validatePropertiesInDevelopment; -var warnForPropDifference; -var warnForExtraAttributes; -var warnForInvalidEventListener; var canDiffStyleForHydrationWarning; -var normalizeHTML; { warnedUnknownTags = { @@ -5412,15 +5403,6 @@ var normalizeHTML; // is often used for testing purposes. // @see https://electronjs.org/docs/api/webview-tag webview: true - }; - - validatePropertiesInDevelopment = function (type, props) { - validateProperties$2(type, props); - validateProperties$1(type, props); - validateProperties(type, props, { - registrationNameDependencies: registrationNameDependencies, - possibleRegistrationNames: possibleRegistrationNames - }); }; // IE 11 parses & normalizes the style attribute as opposed to other // browsers. It adds spaces and sorts the properties in some // non-alphabetical order. Handling that would require sorting CSS @@ -5431,8 +5413,21 @@ var normalizeHTML; // See https://github.com/facebook/react/issues/11807 canDiffStyleForHydrationWarning = canUseDOM && !document.documentMode; +} + +function validatePropertiesInDevelopment(type, props) { + { + validateProperties$2(type, props); + validateProperties$1(type, props); + validateProperties(type, props, { + registrationNameDependencies: registrationNameDependencies, + possibleRegistrationNames: possibleRegistrationNames + }); + } +} - warnForPropDifference = function (propName, serverValue, clientValue) { +function warnForPropDifference(propName, serverValue, clientValue) { + { if (didWarnInvalidHydration) { return; } @@ -5452,9 +5447,11 @@ var normalizeHTML; JSON.stringify(normalizedServerValue), JSON.stringify(normalizedClientValue) ); - }; + } +} - warnForExtraAttributes = function (attributeNames) { +function warnForExtraAttributes(attributeNames) { + { if (didWarnInvalidHydration) { return; } @@ -5466,9 +5463,11 @@ var normalizeHTML; }); error("Extra attributes from the server: %s", names); - }; + } +} - warnForInvalidEventListener = function (registrationName, listener) { +function warnForInvalidEventListener(registrationName, listener) { + { if (listener === false) { error( "Expected `%s` listener to be a function, instead got `false`.\n\n" + @@ -5485,10 +5484,12 @@ var normalizeHTML; typeof listener ); } - }; // Parse the HTML and read it back to normalize the HTML string so that it - // can be used for comparison. + } +} // Parse the HTML and read it back to normalize the HTML string so that it +// can be used for comparison. - normalizeHTML = function (parent, html) { +function normalizeHTML(parent, html) { + { // We could have created a separate document here to avoid // re-initializing custom elements if they exist. But this breaks // how