MCPcopy Create free account
hub / github.com/darkreader/darkreader / onAdoptedSheetsChange

Function onAdoptedSheetsChange

src/inject/dynamic-theme/stylesheet-proxy.ts:276–295  ·  view source on GitHub ↗
(node: Document | ShadowRoot)

Source from the content-addressed store, hash-verified

274 };
275
276 const onAdoptedSheetsChange = (node: Document | ShadowRoot) => {
277 const prev = adoptedSheetsSnapshots.get(node);
278 const curr = (node.adoptedStyleSheets || []).filter((s) => !isDRAdoptedSheetOverride(s));
279 adoptedSheetsSnapshots.set(node, curr);
280 if (!prev || !areArraysEqual(prev, curr)) {
281 curr.forEach((sheet) => {
282 if (!adoptedSheetOwners.has(sheet)) {
283 adoptedSheetOwners.set(sheet, new Set());
284 }
285 adoptedSheetOwners.get(sheet)!.add(node);
286 for (const rule of sheet.cssRules) {
287 const declaration = (rule as CSSStyleRule).style;
288 if (declaration) {
289 adoptedDeclarationSheets.set(declaration, sheet);
290 }
291 }
292 });
293 node.dispatchEvent(adoptedSheetsChangeEvent);
294 }
295 };
296
297 const proxyAdoptedSheetsArray = (node: Document | ShadowRoot, source: CSSStyleSheet[]) => {
298 if (adoptedSheetsProxySources.has(source)) {

Callers 2

setFunction · 0.70
injectProxyFunction · 0.70

Calls 6

isDRAdoptedSheetOverrideFunction · 0.85
areArraysEqualFunction · 0.85
addMethod · 0.80
getMethod · 0.65
setMethod · 0.65
hasMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…