@@ -1027,7 +1027,13 @@ export function isHydratableType(type: string, props: Props): boolean {
1027
1027
if ( enableFloat ) {
1028
1028
if ( type === 'script' ) {
1029
1029
const { async , onLoad , onError } = ( props : any ) ;
1030
- return ! ( async && ( onLoad || onError ) ) ;
1030
+ return ! (
1031
+ ! async ||
1032
+ onLoad ||
1033
+ onError ||
1034
+ typeof async === 'function' ||
1035
+ typeof async === 'symbol'
1036
+ ) ;
1031
1037
}
1032
1038
return true ;
1033
1039
} else {
@@ -2455,9 +2461,15 @@ export function getResource(
2455
2461
return null;
2456
2462
}
2457
2463
case 'script': {
2458
- if (typeof pendingProps.src === 'string' && pendingProps.async === true) {
2459
- const scriptProps: ScriptProps = pendingProps;
2460
- const key = getScriptKey(scriptProps.src);
2464
+ const async = pendingProps.async;
2465
+ const src = pendingProps.src;
2466
+ if (
2467
+ typeof src === 'string' &&
2468
+ async &&
2469
+ typeof async !== 'function' &&
2470
+ typeof async !== 'symbol'
2471
+ ) {
2472
+ const key = getScriptKey(src);
2461
2473
const scripts = getResourcesFromRoot(resourceRoot).hoistableScripts;
2462
2474
2463
2475
let resource = scripts.get(key);
@@ -3103,15 +3115,24 @@ export function isHostHoistableType(
3103
3115
}
3104
3116
case 'script': {
3105
3117
if (
3106
- props.async !== true ||
3118
+ // This is ordered to hopefully hit an exclusion case as early as possible
3119
+ // Logically the async checks together form a "truthy and not function/symbol" which is
3120
+ // how the prop is serialized on a regular HostComponent
3121
+ !props.async ||
3107
3122
props.onLoad ||
3108
3123
props.onError ||
3109
- typeof props.src !== 'string' ||
3110
- !props.src
3124
+ !props.src ||
3125
+ typeof props.async === 'function' ||
3126
+ typeof props.async === 'symbol' ||
3127
+ typeof props.src !== 'string'
3111
3128
) {
3112
3129
if (__DEV__) {
3130
+ const isAsync =
3131
+ props.async &&
3132
+ typeof props.async !== 'function' &&
3133
+ typeof props.async !== 'symbol';
3113
3134
if (outsideHostContainerContext) {
3114
- if (props.async !== true ) {
3135
+ if (!isAsync ) {
3115
3136
console.error(
3116
3137
'Cannot render a sync or defer <script> outside the main document without knowing its order.' +
3117
3138
' Try adding async="" or moving it into the root <head> tag.',
0 commit comments