Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 27 additions & 6 deletions packages/react-devtools-extensions/src/main/cloneStyleTags.js
Original file line number Diff line number Diff line change
@@ -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<HTMLLinkElement | HTMLStyleElement> {
const tags: Array<HTMLLinkElement | HTMLStyleElement> = [];

// eslint-disable-next-line no-for-of-loops/no-for-of-loops
for (const linkTag of document.getElementsByTagName('link')) {
Expand All @@ -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;
}
2 changes: 1 addition & 1 deletion packages/react-devtools-extensions/src/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion packages/react-devtools-extensions/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ module.exports = {
{
loader: 'css-loader',
options: {
sourceMap: true,
sourceMap: __DEV__,
modules: true,
localIdentName: '[local]___[hash:base64:5]',
},
Expand Down
Loading