Repository: facebook/react
File: packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js (JavaScript)

Code before:
      uniquePart += '[' + imageSizes + ']';
    }
  } else {
    uniquePart += '[][]' + href;
  }
  return getResourceKey('image', uniquePart);
}

function pushImg(
  target: Array<Chunk | PrecomputedChunk>,
  props: Object,
  resources: Resources,
): null {
  const {src, srcSet} = props;
  if (
    props.loading !== 'lazy' &&
    typeof src === 'string' &&
    props.fetchPriority !== 'low' &&
    // We exclude data URIs in src and srcSet since these should not be preloaded
    !(
      src[4] === ':' &&
      (src[0] === 'd' || src[0] === 'D') &&
      (src[1] === 'a' || src[1] === 'A') &&
      (src[2] === 't' || src[2] === 'T') &&
      (src[3] === 'a' || src[3] === 'A')
    ) &&
    !(
      typeof srcSet === 'string' &&
      srcSet[4] === ':' &&
      (srcSet[0] === 'd' || srcSet[0] === 'D') &&
      (srcSet[1] === 'a' || srcSet[1] === 'A') &&
      (srcSet[2] === 't' || srcSet[2] === 'T') &&
      (srcSet[3] === 'a' || srcSet[3] === 'A')
    )
  ) {
    // We have a suspensey image and ought to preload it to optimize the loading of display blocking
    // resources.
    const {sizes} = props;
    const key = getImagePreloadKey(src, srcSet, sizes);
    let resource = resources.preloadsMap.get(key);
    if (!resource) {
      resource = {
        type: 'preload',
        chunks: [],
        state: NoState,
        props: {
          rel: 'preload',
          as: 'image',
          // There is a bug in Safari where imageSrcSet is not respected on preload links
          // so we omit the href here if we have imageSrcSet b/c safari will load the wrong image.
          // This harms older browers that do not support imageSrcSet by making their preloads not work

Review comment (suggestion):
```suggestion
      src[0].toLowerCase() === 'd' &&
      src[1].toLowerCase() === 'a' &&
      src[2].toLowerCase() === 't' &&
      src[3].toLowerCase() === 'a'
```


Code after:
      uniquePart += '[' + imageSizes + ']';
    }
  } else {
    uniquePart += '[][]' + href;
  }
  return getResourceKey('image', uniquePart);
}

function pushImg(
  target: Array<Chunk | PrecomputedChunk>,
  props: Object,
  resources: Resources,
): null {
  const {src, srcSet} = props;
  if (
    props.loading !== 'lazy' &&
    (typeof src === 'string' || typeof srcSet === 'string') &&
    props.fetchPriority !== 'low' &&
    // We exclude data URIs in src and srcSet since these should not be preloaded
    !(
      typeof src === 'string' &&
      src[4] === ':' &&
      (src[0] === 'd' || src[0] === 'D') &&
      (src[1] === 'a' || src[1] === 'A') &&
      (src[2] === 't' || src[2] === 'T') &&
      (src[3] === 'a' || src[3] === 'A')
    ) &&
    !(
      typeof srcSet === 'string' &&
      srcSet[4] === ':' &&
      (srcSet[0] === 'd' || srcSet[0] === 'D') &&
      (srcSet[1] === 'a' || srcSet[1] === 'A') &&
      (srcSet[2] === 't' || srcSet[2] === 'T') &&
      (srcSet[3] === 'a' || srcSet[3] === 'A')
    )
  ) {
    // We have a suspensey image and ought to preload it to optimize the loading of display blocking
    // resources.
    const {sizes} = props;
    const key = getImagePreloadKey(src, srcSet, sizes);
    let resource = resources.preloadsMap.get(key);
    if (!resource) {
      resource = {
        type: 'preload',
        chunks: [],
        state: NoState,
        props: {
          rel: 'preload',
          as: 'image',
          // There is a bug in Safari where imageSrcSet is not respected on preload links
          // so we omit the href here if we have imageSrcSet b/c safari will load the wrong image.