• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

IgniteUI / igniteui-webcomponents / 15753383816

19 Jun 2025 08:33AM UTC coverage: 98.266% (+0.009%) from 98.257%
15753383816

Pull #1746

github

web-flow
Merge f7f9c96b3 into 56a6e7062
Pull Request #1746: refactor: Dropped themes decorator for explicit initialization

4943 of 5189 branches covered (95.26%)

Branch coverage included in aggregate %.

435 of 447 new or added lines in 71 files covered. (97.32%)

8 existing lines in 1 file now uncovered.

31497 of 31894 relevant lines covered (98.76%)

1728.24 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

96.74
/src/theming/utils.ts
1
import { isServer } from 'lit';
69✔
2

69✔
3
function isStyleRule(rule: CSSRule): rule is CSSStyleRule {
1✔
4
  return rule != null && 'style' in rule;
1✔
5
}
1✔
6

69✔
7
function cssKeyToJsKey(key: string): string {
2✔
8
  return key.replace(/^--|-./g, (match) => {
2✔
9
    return match.startsWith('--') ? '' : match.charAt(1).toUpperCase();
5✔
10
  });
2✔
11
}
2✔
12

69✔
13
function getAllCssVariableNames(): Set<string> {
63✔
14
  const cssVars = new Set<string>();
63✔
15
  const styleSheets = Array.from(document.styleSheets);
63✔
16

63✔
17
  for (const sheet of styleSheets) {
63✔
18
    let rules: CSSRuleList | undefined;
2✔
19

2✔
20
    // Potential CORS or access errors
2✔
21
    try {
2✔
22
      rules = sheet.cssRules;
2✔
23
    } catch {
2✔
24
      continue;
1✔
25
    }
1✔
26

1✔
27
    if (!rules) {
2!
NEW
28
      continue;
×
NEW
29
    }
✔
30

1✔
31
    for (const rule of Array.from(rules)) {
1✔
32
      if (isStyleRule(rule)) {
1✔
33
        const length = rule.style.length;
1✔
34

1✔
35
        for (let i = 0; i < length; i++) {
1✔
36
          const style = rule.style[i];
2✔
37

2✔
38
          if (style.startsWith('--')) {
2✔
39
            cssVars.add(style);
2✔
40
          }
2✔
41
        }
2✔
42
      }
1✔
43
    }
1✔
44
  }
1✔
45

63✔
46
  return cssVars;
63✔
47
}
63✔
48

69✔
49
function getElementCssVariables(
63✔
50
  allCssVars: Set<string>,
63✔
51
  element: HTMLElement,
63✔
52
  pseudo?: string
63✔
53
): Record<string, string> {
63✔
54
  const cssVars: Record<string, string> = {};
63✔
55
  const styles = getComputedStyle(element, pseudo);
63✔
56

63✔
57
  for (const key of allCssVars) {
63✔
58
    const value = styles.getPropertyValue(key);
2✔
59

2✔
60
    if (value) {
2✔
61
      cssVars[cssKeyToJsKey(key)] = value.trim();
2✔
62
    }
2✔
63
  }
2✔
64

63✔
65
  return cssVars;
63✔
66
}
63✔
67

69✔
68
export function getAllCssVariables(): Record<string, string> {
69✔
69
  /* c8 ignore next 2 */
69✔
70
  return isServer
69✔
71
    ? {}
69✔
72
    : getElementCssVariables(
63✔
73
        getAllCssVariableNames(),
63✔
74
        document.documentElement
63✔
75
      );
63✔
76
}
63✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc