Files
react/packages/react-devtools-extensions/src/inject.js
Brian Vaughn bce2ac63a9 Revert change to backend injection method from PR #16752 (#16864)
PR #16752 changed how we were injecting the backend script to be done by the content script in order to work around Trusted Type limitations with our previous approach. This may have caused a regression (see #16840) so I'm backing it out to verify.
2019-09-23 12:56:36 -07:00

25 lines
653 B
JavaScript

/* global chrome */
export default function inject(scriptName: string, done: ?Function) {
const source = `
// the prototype stuff is in case document.createElement has been modified
(function () {
var script = document.constructor.prototype.createElement.call(document, 'script');
script.src = "${scriptName}";
script.charset = "utf-8";
document.documentElement.appendChild(script);
script.parentNode.removeChild(script);
})()
`;
chrome.devtools.inspectedWindow.eval(source, function(response, error) {
if (error) {
console.log(error);
}
if (typeof done === 'function') {
done();
}
});
}