13 lines
358 B
JavaScript
13 lines
358 B
JavaScript
|
export const copyCss = (shadow) => {
|
||
|
let css = '';
|
||
|
for (let i = 0; i < document.styleSheets.length; i++) {
|
||
|
const styleSheet = document.styleSheets[i];
|
||
|
for (let j = 0; j < styleSheet.rules.length; j++) {
|
||
|
css += styleSheet.rules[j].cssText;
|
||
|
}
|
||
|
}
|
||
|
const sheet = new CSSStyleSheet();
|
||
|
sheet.replaceSync(css);
|
||
|
shadow.adoptedStyleSheets = [sheet];
|
||
|
};
|