MCPcopy Index your code
hub / github.com/darkreader/darkreader / handleAdoptedStyleSheets

Function handleAdoptedStyleSheets

src/inject/dynamic-theme/index.ts:472–488  ·  view source on GitHub ↗
(node: ShadowRoot | Document)

Source from the content-addressed store, hash-verified

470}
471
472function handleAdoptedStyleSheets(node: ShadowRoot | Document) {
473 if (canHaveAdoptedStyleSheets(node)) {
474 forEach(isFirefox ? unwrap(node.adoptedStyleSheets) : node.adoptedStyleSheets, (s) => {
475 variablesStore.addRulesForMatching(s.cssRules);
476 });
477 const newManger = createAdoptedStyleSheetOverride(node);
478 adoptedStyleManagers.push(newManger);
479 newManger.render(theme!, ignoredImageAnalysisSelectors);
480 newManger.watch((sheets) => {
481 sheets.forEach((s) => {
482 variablesStore.addRulesForMatching(s.cssRules);
483 });
484 variablesStore.matchVariablesAndDependents();
485 newManger.render(theme!, ignoredImageAnalysisSelectors);
486 });
487 }
488}
489
490function watchForUpdates() {
491 const managedStyles = Array.from(styleManagers.keys());

Callers 2

watchForUpdatesFunction · 0.85

Calls 8

forEachFunction · 0.90
unwrapFunction · 0.85
addRulesForMatchingMethod · 0.80
renderMethod · 0.65
watchMethod · 0.65

Tested by

no test coverage detected