Home / Function/ setSrcObject() — react Function Reference

setSrcObject() — react Function Reference

Architecture documentation for the setSrcObject() function in ReactDOMSrcObject.js from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  8234e051_6c96_9381_5d63_a81ad81ddbaf["setSrcObject()"]
  07ac38fd_3da1_78a3_abb5_74bfd98836d2["ReactDOMSrcObject.js"]
  8234e051_6c96_9381_5d63_a81ad81ddbaf -->|defined in| 07ac38fd_3da1_78a3_abb5_74bfd98836d2
  5a792874_dbaf_1dd0_9e62_d6a16580e0b5["setProp()"]
  5a792874_dbaf_1dd0_9e62_d6a16580e0b5 -->|calls| 8234e051_6c96_9381_5d63_a81ad81ddbaf
  style 8234e051_6c96_9381_5d63_a81ad81ddbaf fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/react-dom-bindings/src/client/ReactDOMSrcObject.js lines 10–25

export function setSrcObject(domElement: Element, tag: string, value: any) {
  // We optimistically create the URL regardless of object type. This lets us
  // support cross-realms and any type that the browser supports like new types.
  const url = URL.createObjectURL((value: any));
  const loadEvent = tag === 'img' ? 'load' : 'loadstart';
  const cleanUp = () => {
    // Once the object has started loading, then it's already collected by the
    // browser and it won't refer to it by the URL anymore so we can now revoke it.
    URL.revokeObjectURL(url);
    domElement.removeEventListener(loadEvent, cleanUp);
    domElement.removeEventListener('error', cleanUp);
  };
  domElement.addEventListener(loadEvent, cleanUp);
  domElement.addEventListener('error', cleanUp);
  domElement.setAttribute('src', url);
}

Domain

Subdomains

Called By

Frequently Asked Questions

What does setSrcObject() do?
setSrcObject() is a function in the react codebase, defined in packages/react-dom-bindings/src/client/ReactDOMSrcObject.js.
Where is setSrcObject() defined?
setSrcObject() is defined in packages/react-dom-bindings/src/client/ReactDOMSrcObject.js at line 10.
What calls setSrcObject()?
setSrcObject() is called by 1 function(s): setProp.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free