Skip to content

Commit

Permalink
[Float] treat props.async in Float consistent with the rest of reac…
Browse files Browse the repository at this point in the history
…t-dom (#26760)

Treat async (boolean prop) consistently with Float. Previously float
checked if `props.async === true` (or not true) but the rest of
react-dom considers anything truthy that isn't a function or symbol as
`true`. This PR normalizes the Float behavior.

DiffTrain build for [f62cf8c](f62cf8c)
  • Loading branch information
gnoff committed Apr 8, 2024
1 parent 4638467 commit 550d416
Show file tree
Hide file tree
Showing 11 changed files with 255 additions and 133 deletions.
2 changes: 1 addition & 1 deletion compiled/facebook-www/REVISION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
dfd3d5af83cadd9bfc904c0a62a30adc20e414c9
f62cf8c62052ae780d351090013f7155cf9a868c
28 changes: 18 additions & 10 deletions compiled/facebook-www/ReactDOM-dev.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -36178,7 +36178,7 @@ if (__DEV__) {
return root;
}

var ReactVersion = "19.0.0-www-classic-d3a3b38f";
var ReactVersion = "19.0.0-www-classic-2300aa8f";

function createPortal$1(
children,
Expand Down Expand Up @@ -46172,13 +46172,16 @@ if (__DEV__) {
}

case "script": {
var async = pendingProps.async;
var src = pendingProps.src;

if (
typeof pendingProps.src === "string" &&
pendingProps.async === true
typeof src === "string" &&
async &&
typeof async !== "function" &&
typeof async !== "symbol"
) {
var scriptProps = pendingProps;

var _key2 = getScriptKey(scriptProps.src);
var _key2 = getScriptKey(src);

var scripts = getResourcesFromRoot(resourceRoot).hoistableScripts;

Expand Down Expand Up @@ -46854,16 +46857,21 @@ if (__DEV__) {
}

case "script": {
var isAsync =
props.async &&
typeof props.async !== "function" &&
typeof props.async !== "symbol";

if (
props.async !== true ||
!isAsync ||
props.onLoad ||
props.onError ||
typeof props.src !== "string" ||
!props.src
!props.src ||
typeof props.src !== "string"
) {
{
if (outsideHostContainerContext) {
if (props.async !== true) {
if (!isAsync) {
error(
"Cannot render a sync or defer <script> outside the main document without knowing its order." +
' Try adding async="" or moving it into the root <head> tag.'
Expand Down
28 changes: 18 additions & 10 deletions compiled/facebook-www/ReactDOM-dev.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -44492,13 +44492,16 @@ if (__DEV__) {
}

case "script": {
var async = pendingProps.async;
var src = pendingProps.src;

if (
typeof pendingProps.src === "string" &&
pendingProps.async === true
typeof src === "string" &&
async &&
typeof async !== "function" &&
typeof async !== "symbol"
) {
var scriptProps = pendingProps;

var _key2 = getScriptKey(scriptProps.src);
var _key2 = getScriptKey(src);

var scripts = getResourcesFromRoot(resourceRoot).hoistableScripts;

Expand Down Expand Up @@ -45174,16 +45177,21 @@ if (__DEV__) {
}

case "script": {
var isAsync =
props.async &&
typeof props.async !== "function" &&
typeof props.async !== "symbol";

if (
props.async !== true ||
!isAsync ||
props.onLoad ||
props.onError ||
typeof props.src !== "string" ||
!props.src
!props.src ||
typeof props.src !== "string"
) {
{
if (outsideHostContainerContext) {
if (props.async !== true) {
if (!isAsync) {
error(
"Cannot render a sync or defer <script> outside the main document without knowing its order." +
' Try adding async="" or moving it into the root <head> tag.'
Expand Down Expand Up @@ -45666,7 +45674,7 @@ if (__DEV__) {
return root;
}

var ReactVersion = "19.0.0-www-modern-3e16b8a9";
var ReactVersion = "19.0.0-www-modern-8fd9a43e";

function createPortal$1(
children,
Expand Down
45 changes: 30 additions & 15 deletions compiled/facebook-www/ReactDOM-prod.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -15817,15 +15817,28 @@ function getResource(type, currentProps, pendingProps) {
}
return null;
case "script":
return "string" === typeof pendingProps.src && !0 === pendingProps.async
? ((pendingProps = getScriptKey(pendingProps.src)),
(currentProps = getResourcesFromRoot(currentProps).hoistableScripts),
(type = currentProps.get(pendingProps)),
type ||
((type = { type: "script", instance: null, count: 0, state: null }),
currentProps.set(pendingProps, type)),
type)
: { type: "void", instance: null, count: 0, state: null };
return (
(type = pendingProps.async),
(pendingProps = pendingProps.src),
"string" === typeof pendingProps &&
type &&
"function" !== typeof type &&
"symbol" !== typeof type
? ((pendingProps = getScriptKey(pendingProps)),
(currentProps =
getResourcesFromRoot(currentProps).hoistableScripts),
(type = currentProps.get(pendingProps)),
type ||
((type = {
type: "script",
instance: null,
count: 0,
state: null
}),
currentProps.set(pendingProps, type)),
type)
: { type: "void", instance: null, count: 0, state: null }
);
default:
throw Error(formatProdErrorMessage(444, type));
}
Expand Down Expand Up @@ -16064,11 +16077,13 @@ function isHostHoistableType(type, props, hostContext) {
}
case "script":
if (
!0 === props.async &&
props.async &&
"function" !== typeof props.async &&
"symbol" !== typeof props.async &&
!props.onLoad &&
!props.onError &&
"string" === typeof props.src &&
props.src
props.src &&
"string" === typeof props.src
)
return !0;
}
Expand Down Expand Up @@ -16989,7 +17004,7 @@ Internals.Events = [
var devToolsConfig$jscomp$inline_1727 = {
findFiberByHostInstance: getClosestInstanceFromNode,
bundleType: 0,
version: "19.0.0-www-classic-36046b05",
version: "19.0.0-www-classic-4bf8f875",
rendererPackageName: "react-dom"
};
var internals$jscomp$inline_2156 = {
Expand Down Expand Up @@ -17019,7 +17034,7 @@ var internals$jscomp$inline_2156 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "19.0.0-www-classic-36046b05"
reconcilerVersion: "19.0.0-www-classic-4bf8f875"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_2157 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
Expand Down Expand Up @@ -17485,4 +17500,4 @@ exports.useFormState = function (action, initialState, permalink) {
exports.useFormStatus = function () {
return ReactCurrentDispatcher$2.current.useHostTransitionStatus();
};
exports.version = "19.0.0-www-classic-36046b05";
exports.version = "19.0.0-www-classic-4bf8f875";
45 changes: 30 additions & 15 deletions compiled/facebook-www/ReactDOM-prod.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -15111,15 +15111,28 @@ function getResource(type, currentProps, pendingProps) {
}
return null;
case "script":
return "string" === typeof pendingProps.src && !0 === pendingProps.async
? ((pendingProps = getScriptKey(pendingProps.src)),
(currentProps = getResourcesFromRoot(currentProps).hoistableScripts),
(type = currentProps.get(pendingProps)),
type ||
((type = { type: "script", instance: null, count: 0, state: null }),
currentProps.set(pendingProps, type)),
type)
: { type: "void", instance: null, count: 0, state: null };
return (
(type = pendingProps.async),
(pendingProps = pendingProps.src),
"string" === typeof pendingProps &&
type &&
"function" !== typeof type &&
"symbol" !== typeof type
? ((pendingProps = getScriptKey(pendingProps)),
(currentProps =
getResourcesFromRoot(currentProps).hoistableScripts),
(type = currentProps.get(pendingProps)),
type ||
((type = {
type: "script",
instance: null,
count: 0,
state: null
}),
currentProps.set(pendingProps, type)),
type)
: { type: "void", instance: null, count: 0, state: null }
);
default:
throw Error(formatProdErrorMessage(444, type));
}
Expand Down Expand Up @@ -15358,11 +15371,13 @@ function isHostHoistableType(type, props, hostContext) {
}
case "script":
if (
!0 === props.async &&
props.async &&
"function" !== typeof props.async &&
"symbol" !== typeof props.async &&
!props.onLoad &&
!props.onError &&
"string" === typeof props.src &&
props.src
props.src &&
"string" === typeof props.src
)
return !0;
}
Expand Down Expand Up @@ -16352,7 +16367,7 @@ Internals.Events = [
var devToolsConfig$jscomp$inline_1720 = {
findFiberByHostInstance: getClosestInstanceFromNode,
bundleType: 0,
version: "19.0.0-www-modern-dce39c57",
version: "19.0.0-www-modern-120e5878",
rendererPackageName: "react-dom"
};
var internals$jscomp$inline_2158 = {
Expand Down Expand Up @@ -16382,7 +16397,7 @@ var internals$jscomp$inline_2158 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "19.0.0-www-modern-dce39c57"
reconcilerVersion: "19.0.0-www-modern-120e5878"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_2159 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
Expand Down Expand Up @@ -16691,4 +16706,4 @@ exports.useFormState = function (action, initialState, permalink) {
exports.useFormStatus = function () {
return ReactCurrentDispatcher$2.current.useHostTransitionStatus();
};
exports.version = "19.0.0-www-modern-dce39c57";
exports.version = "19.0.0-www-modern-120e5878";
45 changes: 30 additions & 15 deletions compiled/facebook-www/ReactDOM-profiling.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -16565,15 +16565,28 @@ function getResource(type, currentProps, pendingProps) {
}
return null;
case "script":
return "string" === typeof pendingProps.src && !0 === pendingProps.async
? ((pendingProps = getScriptKey(pendingProps.src)),
(currentProps = getResourcesFromRoot(currentProps).hoistableScripts),
(type = currentProps.get(pendingProps)),
type ||
((type = { type: "script", instance: null, count: 0, state: null }),
currentProps.set(pendingProps, type)),
type)
: { type: "void", instance: null, count: 0, state: null };
return (
(type = pendingProps.async),
(pendingProps = pendingProps.src),
"string" === typeof pendingProps &&
type &&
"function" !== typeof type &&
"symbol" !== typeof type
? ((pendingProps = getScriptKey(pendingProps)),
(currentProps =
getResourcesFromRoot(currentProps).hoistableScripts),
(type = currentProps.get(pendingProps)),
type ||
((type = {
type: "script",
instance: null,
count: 0,
state: null
}),
currentProps.set(pendingProps, type)),
type)
: { type: "void", instance: null, count: 0, state: null }
);
default:
throw Error(formatProdErrorMessage(444, type));
}
Expand Down Expand Up @@ -16812,11 +16825,13 @@ function isHostHoistableType(type, props, hostContext) {
}
case "script":
if (
!0 === props.async &&
props.async &&
"function" !== typeof props.async &&
"symbol" !== typeof props.async &&
!props.onLoad &&
!props.onError &&
"string" === typeof props.src &&
props.src
props.src &&
"string" === typeof props.src
)
return !0;
}
Expand Down Expand Up @@ -17737,7 +17752,7 @@ Internals.Events = [
var devToolsConfig$jscomp$inline_1813 = {
findFiberByHostInstance: getClosestInstanceFromNode,
bundleType: 0,
version: "19.0.0-www-classic-0d6b1c7f",
version: "19.0.0-www-classic-7e57af88",
rendererPackageName: "react-dom"
};
(function (internals) {
Expand Down Expand Up @@ -17781,7 +17796,7 @@ var devToolsConfig$jscomp$inline_1813 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "19.0.0-www-classic-0d6b1c7f"
reconcilerVersion: "19.0.0-www-classic-7e57af88"
});
var ReactFiberErrorDialogWWW = require("ReactFiberErrorDialog");
if ("function" !== typeof ReactFiberErrorDialogWWW.showErrorDialog)
Expand Down Expand Up @@ -18234,7 +18249,7 @@ exports.useFormState = function (action, initialState, permalink) {
exports.useFormStatus = function () {
return ReactCurrentDispatcher$2.current.useHostTransitionStatus();
};
exports.version = "19.0.0-www-classic-0d6b1c7f";
exports.version = "19.0.0-www-classic-7e57af88";
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
"function" ===
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
Expand Down

0 comments on commit 550d416

Please sign in to comment.