MCPcopy
hub / github.com/darkreader/darkreader / getManageableStyles

Function getManageableStyles

src/inject/dynamic-theme/style-manager.ts:98–116  ·  view source on GitHub ↗
(node: Node | null, results: StyleElement[] = [], deep = true)

Source from the content-addressed store, hash-verified

96}
97
98export function getManageableStyles(node: Node | null, results: StyleElement[] = [], deep = true): StyleElement[] {
99 if (shouldManageStyle(node)) {
100 results.push(node as StyleElement);
101 } else if (node instanceof Element || (isShadowDomSupported && node instanceof ShadowRoot) || node === document) {
102 forEach(
103 (node as Element).querySelectorAll(STYLE_SELECTOR) as NodeListOf<StyleElement>,
104 (style: StyleElement) => getManageableStyles(style, results, false),
105 );
106 if (
107 deep && (
108 (node as Element).children?.length > 0 ||
109 (node as Element).shadowRoot
110 )
111 ) {
112 iterateShadowHosts(node, (host) => getManageableStyles(host.shadowRoot, results, false));
113 }
114 }
115 return results;
116}
117
118const syncStyleSet = new WeakSet<HTMLStyleElement | SVGStyleElement>();
119const corsCopies = new WeakMap<StyleElement, CSSStyleSheet>();

Callers 4

handleMinorTreeMutationsFunction · 0.90
handleHugeTreeMutationsFunction · 0.90
watchForStylePositionsFunction · 0.90

Calls 3

forEachFunction · 0.90
iterateShadowHostsFunction · 0.90
shouldManageStyleFunction · 0.85

Tested by

no test coverage detected