You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
extends image preloading to accept imagesrcset and imagesizes to handle cases where srcset and sizes are used over src. Normally we key off an href however in the case of responsive images it is possible that no src attribute is desired. Right now this happens most prominently with Safari which does understand srcset for the img tag but not for the link preload tag. Because of this it can be detrimental to preload with a fallback src since Safari will end up downloading the wrong image 100% of the time.
The solution to this is to allow the user to omit the href if they provide imagesrcset (and optionally) imagesizes. Effectively the key for image preloads will become the union of src (href), imagesrcset, and imagesizes.
'ReactDOM.preload(): Expected two arguments, an `href` string and an `options` object with an `as` property valid for a `<linkrel="preload"as="..."/>` tag. %s',
'ReactDOM.preload(): When preloading as an "image" expected either the `href` argument to be a non-empty string or the `imageSrcSet` option to be a non-empty string or both. The `href` encountered was %s and the `imageSrcSet` encountered was %s.',
'ReactDOM.preload(): Expected the `options` argument (second) to be an object with an `as` property describing the type of resource to be preloaded but encountered %s instead.',
'ReactDOM.preload(): Expected the `as` property in the `options` argument (second) to contain a string value describing the type of resource to be preloaded but encountered %s instead. Values that are valid in for the `as` attribute of a `<link rel="preload" as="..." />` tag are valid here.',
encountered+=`The \`as\` option encountered was ${getValueDescriptorExpectingObjectForWarning(
5083
+
options.as,
5084
+
)}.`;
5085
+
}
5086
+
if(encountered){
5087
+
console.error(
5088
+
'ReactDOM.preload(): Expected two arguments, an `href` string and an `options` object with an `as` property valid for a `<link rel="preload" as="..." />` tag. %s',
'ReactDOM.preload(): When preloading as an "image" expected either the `href` argument to be a non-empty string or the `imageSrcSet` option to be a non-empty string or both. The `href` encountered was %s and the `imageSrcSet` encountered was %s.',
0 commit comments