executeScript() — react Function Reference
Architecture documentation for the executeScript() function in FizzTestUtils.js from the react codebase.
Entity Profile
Dependency Diagram
graph TD 5343ca21_0631_7721_3a23_011487e7c59e["executeScript()"] 7c063c03_f497_41b6_7547_aff9bc8a9af7["FizzTestUtils.js"] 5343ca21_0631_7721_3a23_011487e7c59e -->|defined in| 7c063c03_f497_41b6_7547_aff9bc8a9af7 1ef1d603_31d5_1714_d957_3868b001227f["insertNodesAndExecuteScripts()"] 1ef1d603_31d5_1714_d957_3868b001227f -->|calls| 5343ca21_0631_7721_3a23_011487e7c59e style 5343ca21_0631_7721_3a23_011487e7c59e fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/react-dom/src/test-utils/FizzTestUtils.js lines 81–116
async function executeScript(script: Element) {
const ownerDocument = script.ownerDocument;
if (script.parentNode == null) {
throw new Error(
'executeScript expects to be called on script nodes that are currently in a document',
);
}
const parent = script.parentNode;
const scriptSrc = script.getAttribute('src');
if (scriptSrc) {
if (document !== ownerDocument) {
throw new Error(
'You must set the current document to the global document to use script src in tests',
);
}
try {
// $FlowFixMe
require(scriptSrc);
} catch (x) {
const event = new window.ErrorEvent('error', {error: x});
window.dispatchEvent(event);
}
} else {
const newScript = ownerDocument.createElement('script');
newScript.textContent = script.textContent;
// make sure to add nonce back to script if it exists
for (let i = 0; i < script.attributes.length; i++) {
const attribute = script.attributes[i];
newScript.setAttribute(attribute.name, attribute.value);
}
parent.insertBefore(newScript, script);
parent.removeChild(script);
}
}
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does executeScript() do?
executeScript() is a function in the react codebase, defined in packages/react-dom/src/test-utils/FizzTestUtils.js.
Where is executeScript() defined?
executeScript() is defined in packages/react-dom/src/test-utils/FizzTestUtils.js at line 81.
What calls executeScript()?
executeScript() is called by 1 function(s): insertNodesAndExecuteScripts.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free