diff --git a/packages/react-devtools-extensions/src/main/cloneStyleTags.js b/packages/react-devtools-extensions/src/main/cloneStyleTags.js index dd84e01fc9e..caad2a361ca 100644 --- a/packages/react-devtools-extensions/src/main/cloneStyleTags.js +++ b/packages/react-devtools-extensions/src/main/cloneStyleTags.js @@ -1,5 +1,14 @@ -function cloneStyleTags() { - const linkTags = []; +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @flow + */ + +export function cloneStyleTags(): Array { + const tags: Array = []; // eslint-disable-next-line no-for-of-loops/no-for-of-loops for (const linkTag of document.getElementsByTagName('link')) { @@ -11,11 +20,23 @@ function cloneStyleTags() { newLinkTag.setAttribute(attribute.nodeName, attribute.nodeValue); } - linkTags.push(newLinkTag); + tags.push(newLinkTag); } } - return linkTags; -} + // eslint-disable-next-line no-for-of-loops/no-for-of-loops + for (const styleTag of document.getElementsByTagName('style')) { + const newStyleTag = document.createElement('style'); + + // eslint-disable-next-line no-for-of-loops/no-for-of-loops + for (const attribute of styleTag.attributes) { + newStyleTag.setAttribute(attribute.nodeName, attribute.nodeValue); + } -export default cloneStyleTags; + newStyleTag.textContent = styleTag.textContent; + + tags.push(newStyleTag); + } + + return tags; +} diff --git a/packages/react-devtools-extensions/src/main/index.js b/packages/react-devtools-extensions/src/main/index.js index cec9fd6df45..bc948d1e6d6 100644 --- a/packages/react-devtools-extensions/src/main/index.js +++ b/packages/react-devtools-extensions/src/main/index.js @@ -33,7 +33,7 @@ import { import {viewAttributeSource} from './sourceSelection'; import {startReactPolling} from './reactPolling'; -import cloneStyleTags from './cloneStyleTags'; +import {cloneStyleTags} from './cloneStyleTags'; import fetchFileWithCaching from './fetchFileWithCaching'; import injectBackendManager from './injectBackendManager'; import registerEventsLogger from './registerEventsLogger'; diff --git a/packages/react-devtools-extensions/webpack.config.js b/packages/react-devtools-extensions/webpack.config.js index 4592363c64a..191eabc47cb 100644 --- a/packages/react-devtools-extensions/webpack.config.js +++ b/packages/react-devtools-extensions/webpack.config.js @@ -285,7 +285,7 @@ module.exports = { { loader: 'css-loader', options: { - sourceMap: true, + sourceMap: __DEV__, modules: true, localIdentName: '[local]___[hash:base64:5]', },